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 |
sqlfresher2k7
Aged Yak Warrior
623 Posts |
Posted - 2009-04-21 : 13:57:47
|
I want a script which should execute the alter if the column doesn't exists in the table..IF exists(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'Student_ID') ALTER TABLE dbo.student_info ADD Student_ID bigint NOT NULL IDENTITY(1,1) |
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2009-04-21 : 14:08:43
|
[code]IF exists(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'Student_ID' and table_name='student_info') ALTER TABLE dbo.student_info ADD Student_ID bigint NOT NULL IDENTITY(1,1)[/code] |
|
|
sqlfresher2k7
Aged Yak Warrior
623 Posts |
Posted - 2009-04-21 : 17:42:01
|
Thanks it works.. |
|
|
dsindo
Starting Member
45 Posts |
Posted - 2009-04-24 : 19:43:10
|
IF not exists(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'Student_ID' and table_name='student_info') ALTER TABLE dbo.student_info ADD Student_ID bigint NOT NULL IDENTITY(1,1) |
|
|
|
|
|