Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Table name in SQL Parameters
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00795824
Message ID:
00795831
Views:
14
You've to build and run dynamic sql using EXECUTE command or sp_executesql system sproc.
Declare @Myparam as Varchar(50), @SqlStr varchar (512)

Set @MyParam = 'TableName'

SET @SqlStr = 'Select * from A_Table as T1 Left join ' + ;
		@MyParam + ' as T2 on T2.Id=T1.Id'

EXECUTE (@SqlStr)
>How can I pass a table name as a parameter in SQL Server 2000 stored procedure?
>
>For exemple:
>
>Declare @Myparam as Varchar(50)
>
>Set @MyParam = 'TableName'
>
>Select * from A_Table as T1
>Left join @MyParam as T2 on T2.Id=T1.Id
>
>
>This sample does not work, but It represent what I'd like to do
>
>Thanks
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform