Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Troubleshoot
Message
De
04/10/2006 15:55:48
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01159501
Message ID:
01159506
Vues:
14
>Hi All,
> I this simple t-sql statement:
>
>
>Declare @Meet char(10),
> @cmd varchar(20)
>
>set @Meet = 'Meet152'
>Select @Cmd = 'Use ' + @Meet
>exec(@cmd)
>
>When I execute this in a query analyzer, it completes successfully, however this does not opens a Meet152 database.
>
> What am I doing wrong here?
>
>Thanks so much!!!

It does, but not in your current batchm becuase you use dynamic SQL it open Meet152 DB in separate batch, if you try:
Declare @Meet char(10),
        @cmd varchar(20)

set @Meet = 'Meet152'
Select @Cmd = 'Use ' + @Meet + '; SELECT * from SomeTableWhichIsInMeet152'
exec(@cmd)
You will get result set
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform