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 |
|
EA
Starting Member
19 Posts |
Posted - 2007-11-15 : 07:51:52
|
| I would like to execute the result of the following SQL in a job:select 'alter database ' + sd.name + ' modify file (name=N''' + sm.name+''', filegrowth = 100MB)'from sys.master_files sm join sys.databases sd on sd.database_id=sm.database_idwhere is_percent_growth=1 and sd.database_id>4I can't get it into a job..... the quotes are driving me mad I'm trying the construction:begindeclare @Str varchar(500)select @str='select 'alter database ''' + sd.name from sys.master_files sm join sys.databases sd on sd.database_id=sm.database_idwhere is_percent_growth=1 and sd.database_id>4'print @str exec (@str)end Any help is very welcome! |
|
|
Hommer
Aged Yak Warrior
808 Posts |
Posted - 2007-11-15 : 10:16:30
|
| It seems you want to select a group of database then apply change to their file growth properties.Why don't you break that down to two steps? Use the select to get those that meet your criteria, then use cursor to loop through each.To make it work in dynamic sql, you can start with regular sql with hard coded variable then swap it out.But over all, this is a one time deal to me, I mean I couldn't image you have to change filegrowth again and again. So you might manually script the whole thing. |
 |
|
|
EA
Starting Member
19 Posts |
Posted - 2007-11-15 : 11:26:47
|
| I will try to work it out using your suggestions, thanx!It isn't a one time job. I'm using a clustered SQL Server. When there's a node switch my growth parameters are all f*#$@ by MS!So everytime after a node switch I need to correct this. It's a 'known-feature' :) |
 |
|
|
|
|
|