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:
01328997
Views:
11
>>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?

No.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform