sql server 2005 - Is there a way to include go in dymanic SQL? -



sql server 2005 - Is there a way to include go in dymanic SQL? -

declare @sql varchar(100) declare @dbname varchar(100)-- set @dbname = 'somedbname'-- set @sql = 'use [' + @dbname + ']' + char(13) + char(10) set @sql = @sql + 'go' + char(13) + char(10)-- print command exec (@sql)

when run gives error wrong syntax near 'go' has found workaround this?

requirement : need include stored procedure creation in switched database.

go not sql statement - a command recognized sql server utilities (e.g. sqlcmd, osql, sql server management studio code editor).

however, can change database without go command.

sql sql-server-2005

Comments

Popular posts from this blog

c# - Move local mssql database to webhosted MYSQL -

java - How to pass parameters between Request-Scoped Controllers? -

string - what is the difference between "some" == "some\0" and strcmp("some","some\0") in c++? -