Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Tablenames as variables?
Message
De
17/04/2005 12:08:57
 
 
À
17/04/2005 11:48:44
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01005583
Message ID:
01005588
Vues:
23
>Suppose one has a SP with parameter @Table, I'd like to
>
>SELECT * FROM @Table WHERE ....
>
>Only, it does not work that way, so if you know of a way, please let me know.
>
>TIA

You can do this with
EXECUTE ('SELECT * FROM '+@Table+' WHERE ...')
or with
SELECT @SQLString='SELECT * FROM '+@Table+' WHERE ...'
EXEC sp_executesql @SQLString
but these have various restrictions.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform