Friday, October 10, 2008

Dynamic Sql-server Table name as a variable


Create procedure s_ProcTable
@TableName varchar(128)
as

declare @sql varchar(4000)
select @sql = 'select * from [' + @TableName + ']'
exec (@sql)
go
s_ProcTable 'Your Proc Name'

No comments: