For the query:
ALTER TABLE table1ADD DEFAULT ('') FOR col1
I have 100 existing columns to add default(''), is there anything like
ALTER TABLE table1ADD DEFAULT ('') FOR col1, col2, col3...
which I can use?
For the query:
ALTER TABLE table1ADD DEFAULT ('') FOR col1
I have 100 existing columns to add default(''), is there anything like
ALTER TABLE table1ADD DEFAULT ('') FOR col1, col2, col3...
which I can use?
No, but you can use SQL to generate the SQL statements.
SELECT 'ALTER TABLE table1 ADD DEFAULT ('''') FOR '+ COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME='table1'
This will generate an ALTER TABLE line for each and every column in your table. Don't worry, these lines are just text output! Now you can copy to clipboard, paste into a SQL Server Management Studio window, delete the lines that you DON'T want the default applied to, and execute.