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?
AT TIME ZONE APPLIES TO:
ONLY.
Change your sql server project type to SQL Server 2016 (or Microsoft Azure SQL Database V12).