Let say I have a simple Stored Procedure:
ALTER PROCEDURE [dbo].[myProc]
SELECT * FROM myTable
SELECT * FROM myProc WHERE x = 'a'; -- But that doesn't work...
It sounds like you're trying to make a "dynamic" stored procedure.
Something you might want to do is:
1) Insert the contents of your stored procedure into a temporary table
2) Use dynamic sql to apply a where condition to that temporary table.
declare @as_condition varchar(500); --Your condition create table #a ( id bigint ) insert into #a execute sproc declare @ls_sql varchar(max); set @ls_sql = "select * from #a where " + @as_condition; execute (@ls_sql);