Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
@VarName as Table Name in SQL
Message
 
 
À
07/07/2003 22:24:04
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00807803
Message ID:
00807809
Vues:
17
Aston,

You can build SQL string and execute it dynamicaly with EXECUTE command or sp_executesql system stored procedure.
DECLARE @Sql varchar(256)
SET @Sql = 'SELECT fld1 FROM [' +  @lcTableName + ']'
EXECUTE (@Sql)
>Hi all,
>
>Does it allow us to put @Variable as table name in SQL Statemnt, cause I want to build a Stored Proc allow me to call any table by the parameter, but I meet a error.
>
>SELECT fld1 FROM [@lcTableName]
>
>Thanks for your help
>Aston
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform