VSTS 2008 Database Edition 似乎不知道“DATEADD”;常数,有什么想法吗?
我正在尝试使用 VSTS 2008 数据库版本实现数据库构建。构建总是在以下约束下失败:
ALTER TABLE [dbo].[tablename]
ADD CONSTRAINT [DF_tablename_date] DEFAULT (CONVERT([varchar],dateadd(hour,(-1),getdate()),(1))) FOR [date];
它显示的错误如下:
TSD03082: The name "hour" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
有人知道这里出了什么问题吗?
I'm trying to implement a database build using VSTS 2008 Database Edition. The build always fails on the following constraint:
ALTER TABLE [dbo].[tablename]
ADD CONSTRAINT [DF_tablename_date] DEFAULT (CONVERT([varchar],dateadd(hour,(-1),getdate()),(1))) FOR [date];
The error that it shows is the following:
TSD03082: The name "hour" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
Anybody have an idea what is wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过将
hour
括在方括号[hour]
中?Have you tried wrapping
hour
in square brackets,[hour]
?在MSDN上问了同样的问题:
http://social .msdn.microsoft.com/Forums/en-US/vstsdb/thread/24afdc7e-3cef-4322-99ff-76ac5174cf3c/
看起来这是一个错误。线程中建议了一种解决方法。
Asked the same question on MSDN:
http://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/24afdc7e-3cef-4322-99ff-76ac5174cf3c/
Looks like it's a bug. A workaround has been suggested in the thread.