这是我的代码:
DECLARE @1day AS VARCHAR(MAX), @sqlText AS NVARCHAR(MAX), @firstdate AS DATETIME
SET @firstdate = DATEADD(dd,-(DAY(GETDATE())-1),GETDATE())
SET @1day = CONVERT(VARCHAR(MAX), @firstdate, 103)
SET @sqlText = 'SELECT ' + 'Dummy' + ' AS ' + @1day
EXEC (@sqlText)
我收到错误消息:[Err] 42000 - [SQL Server]'01' 附近的语法不正确。
预期结果是:
01/06/2013
==========
Dummy
感谢帮助。