Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
USE with a variable
Message
 
 
To
22/03/2011 12:21:15
General information
Forum:
Microsoft SQL Server
Category:
Scripting
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01504526
Message ID:
01504532
Views:
65
This message has been marked as the solution to the initial question of the thread.
It doesn't work either because USE command is scoped to a batch.

>The only way I have found to do this is by executing everything into a command:
>
>
>DECLARE @Command nvarchar(max)
>DECLARE @DestinationDatabase char(40)
>
>SET @DestinationDatabase='Test'
>
>SET @Command='USE '+@DestinationDatabase
>
>EXECUTE(@Command)
>
>
>If someone has a simpler way, please, let us know.
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform