10 Eylül 2012 Pazartesi

mssql - how to remove null constraint

i spent almost 5 hours for removing a null constraint this evening !!!
here is how to do so:

to view constraints on a table: (http://bytes.com/topic/sql-server/answers/710346-how-do-i-view-table-information-such-constraints)

EXEC sp_help  ThisIsMyTable


to drop a constraint:

ALTER TABLE [ThisIsMyTable] DROP CONSTRAINT [ConstraintName]


to make a non-nullable field nullable: (http://stackoverflow.com/questions/3370159/how-to-remove-not-null-constraint-in-sql-server-using-query)

ALTER TABLE  ThisIsMyTable ALTER COLUMN ThisIsTheColumn int NULL

Hiç yorum yok:

Yorum Gönder