How to set a DateTime variable in SQL Server 2008? August 21, 2023 by Tarik You need to enclose the date time value in quotes: DECLARE @Test AS DATETIME SET @Test="2011-02-15" PRINT @Test