ALTER PROCEDURE [dbo].[sp_tablenametest] @table_name varchar(50), @PMId int, @ValueEq int AS BEGIN SET NOCOUNT ON; DECLARE @cmd AS NVARCHAR(max) SET @cmd = N'SELECT * FROM ' + @table_name + ' WHERE Column1 = ''' + @PMId + '''' + ' AND Column2= ''' + @ValueEq + '''' EXEC sp_executesql @cmd END