Monday, September 14, 2009

Query for creating store procedure for running dynamic table with single Procedure

create procedure select_table_dynamic @table_name nvarchar(1000) as
Declare @table nVarchar(1000)
set @table = 'select * from ' + @table_name
exec(@table)

Run Store Procedure

Exec  select_table_dynamic 'table_name'

No comments: