Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dynamically pass database name to USE
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01483661
Message ID:
01483669
Vues:
54
Hi, Elgin,

I'm not positive on this- but I don't believe you can use dynamic SQL simply for a line of code that changes the database (using a USE).

The reason is that dynamic SQL returns to the previous context before it executed.

To the best of my awareness, you'd need to string together some statements with a semicolon...

i.e. USE MyDatabase ; select * from sometable where 1=0 , ETC.

Again, I'm not certain on this, but I didn't think you could execute a single line of dynamic SQL just to change database context.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform