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

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

actionscript 3 - Flex: moving a point with rotation doesnt change the point XY? -

ms access - C# - Using OleDbParameter on table name -