create procedure
declare @tablename varchar(30)
create procedure dbo.Test
@tablename varchar(30),
@val int
as
DECLARE @cmd AS NVARCHAR(max)
SET @cmd = N'SELECT * FROM ' + @table_name +' WHERE Column1 = ''' + @val + ''''
EXEC sp_executesql @cmd
exec Test
No comments:
Post a Comment