I am trying to switch the existing database with the SQL statement. I tried the following, but all attempts failed:
- USE @DatabaseName
- EXEC sp_sqlexec @sql - where @ sql = 'USE [' + + DatabaseName + ']]'
To add a little further detail.
EDIT: I want to do several things on two different databases, where both are configured with one variable i like something like this:
Use Database 1 Select * Table 1 Use Database 2 Select * Table 2
Comments
Post a Comment