Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem adding a new column with constraint
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01327737
Message ID:
01328993
Views:
13
>It still doesn't work.
>
>IF NOT EXISTS
>(SELECT column_name
>FROM INFORMATION_SCHEMA.COLUMNS
>WHERE TABLE_NAME = N'Volunteers' and COLUMN_NAME = N'IsActive')
>BEGIN
>  SET @SQLString = N'alter table Volunteers add IsActive bit null CONSTRAINT [DF_Volunteers_IsActive]  DEFAULT ((1))'
>  EXECUTE sp_executesql @SQLString -- Only to be in other batch
>  UPDATE Volunteers SET IsActive = 1
>END
>
>Gives me an error on UPDATE line.

Did you have BEGIN TRANSACTION before that code?
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform