how to Declare Table and assign select Query.

Jayakumars
Posted by Jayakumars under Sql Server category on | Points: 40 | Views : 1661
hi
I have Declare Table Name and pass the select Query.


DECLARE @execquery AS NVARCHAR(MAX)
DECLARE @tablename AS NVARCHAR(128)
SET @tablename = 'employee'
SET @execquery = N'SELECT * FROM ' + QUOTENAME(@tablename)
EXECUTE sp_executesql @execquery

Comments or Responses

Login to post response