tom.moore.777 89426 (1/23/2013)
the whole point is how to change DB context dynamically?
yes it can be done with the same way as you did but need additional code too like :
set @lstr = 'USe ' + @databasename + '; create table Test (id int ) ;'
exec (@lstr)
this will create test table in all the databases passed by @databasename from cursor
-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)