Using a variable as table_name after FROM


i need pass table_name select statement.  doesn't work.

 

declare @variable

set @variable

 

select *

from @variable

 

 

bill

please post t-sql questions forum:

http://forums.microsoft.com/msdn/showforum.aspx?forumid=85&siteid=1

 

have tried using sp_execute_sql. argument procedure sql query string:

 

code snippet

declare @variable

set @variable

 

declare @query

set @query = 'select * from' + @variable

 

exec sp_execute_sql @query

 

 

hope helps

shuvro



SQL Server  >  Data Mining



Comments

Popular posts from this blog

Conditional formatting a graph vertical axis in SSRS 2012 charts

Register with Power BI failed

SQL server replication error Cannot find the dbo or user defined function........