请告诉我为什么这段代码会抛出错误
我一生都无法弄清楚这段代码出了什么问题:
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'."
I can not for the life of me figure out what is wrong with this code:
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'
I keep getting this error:
"Msg 207, Level 16, State 1, Line 51
Invalid column name 'Report_Date'."
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 alter table 之后放置 GO
Put a GO after alter table