how to use variable in place of tablenamegreenspun.com : LUSENET : SQL Server Database Administration : One Thread
sir, can i use variables in the select statement. if i want to create a variable & used in place of table name this will give me error.
please help me if i want to use variable in place of table name
declare @mvar varchar(50) select @mvar='Employee' select * from @mvar -- error shows @mvar not found ?????
-- Anonymous, September 19, 2001
Create a string that contains the Transact SQL statement that you want to execute, then use the EXEC statement to exectute it.
-- Anonymous, September 20, 2001