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 |
|
Chopsmum
Starting Member
38 Posts |
Posted - 2006-04-24 : 05:33:22
|
| Dear Friends,I've missed something, Im guessing I have to nest for or within Where but cant see itPlease helpHeres my attemptuse RIQDB1IF EXISTS (SELECT DISTINCT 'Alter table '+ table_name + ' ADD CONSTRAINT DF_'+ table_name + '_' + column_name + 'DEFAULT ' + '’’ FOR ' column_name FROM Information_schema.columns WHERE column_name ='%Title%' OR column_name ='%Description%'GoCm |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-04-24 : 05:36:06
|
| What do you want to do?MadhivananFailing to plan is Planning to fail |
 |
|
|
Chopsmum
Starting Member
38 Posts |
Posted - 2006-04-24 : 05:39:14
|
| Hi Madhivanan,Thankyou very much for your helpScript intentions1. Generate script that will add a default to any column in any table that has title or description in the column_nameCm |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-04-24 : 05:47:30
|
| What is the default value do you want to set?Run this in QASELECT DISTINCT 'Alter table '+ table_name + ' ADD CONSTRAINT DF_'+ table_name + '_' + column_name + ' DEFAULT ' + ''''' FOR '+ column_name FROM Information_schema.columnsWHERE column_name ='no' OR column_name ='id'Copy the result back to QA and run them one by oneMadhivananFailing to plan is Planning to fail |
 |
|
|
Chopsmum
Starting Member
38 Posts |
Posted - 2006-04-24 : 06:02:20
|
| Dear Madahavan,This worked with like statements. Thankyou Very MuchUSE RIQDB1SELECT DISTINCT 'Alter table '+ table_name + ' ADD CONSTRAINT DF_'+ table_name + '_' + column_name + ' DEFAULT ' + ''''' FOR '+ column_name FROM Information_schema.columns WHERE column_name Like '%Title' OR column_name Like '%Description'Cm |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-04-24 : 10:45:58
|
>>Dear Madahavan,Spell the name correctly MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|