September 24, 2009 at 5:17 am
Declare @requied_size as int
set @requied_size=256
alter database test modify file(name =test,size=@requied_size MB
Unfortunately this is not working.What i need to change here?I would like to put variable in Size parameter..
Thnks,
Litu
September 24, 2009 at 7:27 am
Try using dynamic sql.
September 26, 2009 at 6:56 am
Thanks for your reply.
Could you give me some example.
September 28, 2009 at 7:17 am
Do a search on how to use dynamic sql and you should quickly find out how to do it 🙂
September 28, 2009 at 9:58 am
declare @cmd varchar(max)
select @cmd = 'alter database text ( size = ' + @required_size
exec( @cmd)
September 28, 2009 at 12:15 pm
Steve: That looks like it's missing a close-paren on the string. Or am I missing something?
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
September 28, 2009 at 1:17 pm
Yes, sorry, was providing the idea there.
The code should look like:
declare @cmd varchar(max)
select @cmd = 'alter database test modify file ( size = ' + @required_size + ' MB)'
exec( @cmd)
The idea is that you just build the executable string that you would normally put in code and then execute it.
October 1, 2009 at 12:19 am
Thnks a lot. 🙂
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply