Not able to build SQL Server project with "AT TIME ZONE" in Visual Studio 2015

Viewed 2429

Query with AT TIME ZONE executed as expected in SQL Server 2016. But if I am adding same query in SQL Server project of Visual Studio 2015, I get a build error

Incorrect Syntax near "AT TIME ZONE".

Code:

DECLARE @Result DATETIME
DECLARE @InputDate DATETIME
        @TimeZone NVARCHAR(50)    

SET @Result = @InputDate AT TIME ZONE @TimeZone AT TIME ZONE 'UTC'

Can anyone help me to fix this issue?

1 Answers

AT TIME ZONE APPLIES TO:

  • SQL Server (starting with 2016)
  • Azure SQL Database

ONLY.

Change your sql server project type to SQL Server 2016 (or Microsoft Azure SQL Database V12).

Related