tags:

views:

25

answers:

2

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?

A: 

Have you tried wrapping hour in square brackets, [hour] ?

Mitch Wheat
Doesn't help unfortunately, comes back with same error:"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."
Marcel Marchon
A: 

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.

Marcel Marchon