Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
@VarName as Table Name in SQL
Message
 
 
To
07/07/2003 22:24:04
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00807803
Message ID:
00807809
Views:
16
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--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform