0

我一生都无法弄清楚这段代码有什么问题:

IF NOT EXISTS(SELECT * FROM sys.columns WHERE name = 'Report_Date' 
                       AND object_id = OBJECT_ID('TempTable3'))
    ALTER TABLE TempTable3 ADD Report_Date datetime

--Set "ReportDate" field to the date the data was extracted less one.
UPDATE TempTable3
SET Report_Date = '20100815'

我不断收到此错误:

"Msg 207, Level 16, State 1, Line 51
Invalid column name 'Report_Date'."
4

1 回答 1

1

在 alter table 之后放一个 GO

ALTER TABLE TempTable3 ADD Report_Date datetime
GO
于 2010-08-16T14:50:50.123 回答