Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
rowter
Yak Posting Veteran
76 Posts |
Posted - 2010-12-29 : 13:29:38
|
| Hi,I need to add a column to a sql server 2005 Express Database Table. The column should not have NULL values. I am using something like this.How can i create this column with a NOT NULL. Should i use a constraint?Error: Incorrect syntax near 'NULL'.IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'my_Lkup' AND COLUMN_NAME = 'IsDeleted')BEGINAlter Table my_Lkup ADD IsDeleted Char(1) NOT NULLThis also failedIF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'my_Lkup' AND COLUMN_NAME = 'IsDeleted')BEGINAlter Table my_Lkup ADD IsDeleted Char(1) Constraint C_IsDel NOT NULLThanks |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
rowter
Yak Posting Veteran
76 Posts |
Posted - 2010-12-29 : 14:45:16
|
| Thanks tkizer that worked |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|