December 11, 2009 at 8:43 am
Hi,
I am trying to execute some script in a list of dbs. i wrote a generic script to change the db which is not working. Please find below the code.
Declare @sqlcmd varchar(max)
Select @sqlcmd = 'use testdb'
Exec (@sqlcmd)
The above script is not changing the db as desired. Please help. Thanks in advance.
December 11, 2009 at 8:53 am
haichells (12/11/2009)
Hi,I am trying to execute some script in a list of dbs. i wrote a generic script to change the db which is not working. Please find below the code.
Declare @sqlcmd varchar(max)
Select @sqlcmd = 'use testdb'
Exec (@sqlcmd)
The above script is not changing the db as desired. Please help. Thanks in advance.
Please read the jeff moden article added in my signature.
Muthukkumaran Kaliyamoorthy
https://www.sqlserverblogforum.com/
December 11, 2009 at 9:01 am
Similar question (and answer) here: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=130994
Recommended article here: http://www.sommarskog.se/dynamic_sql.html
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
December 11, 2009 at 9:26 am
Thanks RyanRandall ! It helps !
Muthukkumaran, Thanks for you too 🙂 Will try forum etiquette
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply