Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem adding a new column with constraint
Message
De
04/07/2008 13:09:21
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01327737
Message ID:
01328993
Vues:
14
>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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform