此 sql 有效:
WITH A AS
(SELECT TOP 1000 *
FROM dbo.SomeTable)
SELECT * FROM A
虽然这个给出了一个错误(关键字'DECLARE'附近的语法不正确):
WITH A AS
(SELECT TOP 1000 *
FROM dbo.SomeTable)
DECLARE @dt DATETIME
SET @dt = GETDATE()
SELECT * FROM A
PRINT DATEDIFF(SS,GETDATE(),@dt)
为什么?