You could perhaps turn it on its head and have the SProc use a function to get the actual data? i.e. where the Function is responsible for getting the appropriate data that you currently envisage being passed to the SProc [by the applicaiton]Something like:USE NOrthwindgoCREATE TABLE org( org_id int, or_type varchar(10))GOINSERT INTO orgSELECT 1, 'A' UNION ALLSELECT 2, 'A' UNION ALLSELECT 3, 'A' UNION ALLSELECT 4, 'B' UNION ALLSELECT 5, 'B'GOCREATE FUNCTION dbo.MyFunction( @or_type varchar(10))RETURNS TABLEASRETURN SELECT org_id FROM dbo.org WHERE or_type = @or_typeGOCREATE PROCEDURE A @or_type varchar(10)ASSET NOCOUNT ON SELECT * FROM dbo.org B JOIN dbo.MyFunction(@or_type) X ON X.org_id = B.org_idGOEXEC A 'A'EXEC A 'B'GODROP TABLE orgDROP PROCEDURE ADROP FUNCTION dbo.MyFunction
Kristen