title: datepart function not working in sql azure
body: <p>I want to split date part like year and assign it to a variable in a stored procedure.
  I run that stored procedure in sql azure. it throws error "<strong>Reference to database and/or server name in 'MASTER..spt_values' is not supported in this version of SQL Server.</strong>"</p>
  
  <p>Code:</p>
  
  <pre class="lang-sql prettyprint-override"><code>declare @Year int
  SET @Year =DATEPART(YYYY,GETDATE())
  create table #SundayDates (Sunday datetime,NextSunday datetime)
  INSERT INTO #SundayDates(Sunday,NextSunday)
  SELECT max(dates),MAX(DATEADD(DD,+7,dates)) AS last_sunday from
  (
      SELECT dateadd(day,number-1,DATEADD(year,@year-1900,0)) AS dates
      FROM MASTER..spt_values WHERE type='p' and
      number between 1 and DATEDIFF(day,DATEADD(year,@year-1900,0),DATEADD(year,@year-1900+1,0))
  ) as t
  WHERE DATENAME(weekday,dates)='sunday' GROUP BY DATEADD(month,datediff(month,0,dates),0)
  </code></pre>