• That is definitely a cool way to skin the cat.  I have been fascinated by XML since the early days and still am. 

    There have been plenty of times I have wanted to use a single proc to pull back the same columns but with different criteria.  The following is a method I came up with a couple of years ago - has been quite handy.  I actually almost had it published in Sql Svr mag but the editor had concerns over performance (so they decided not to use it), so use it w/ a grain of salt.  In my personal experience, performance has not been an issue and the gains from not using a bunch of "IF" statements, dynamic SQL, or maintaining multiple procs that return the same results has been a winner in my book.  

    CREATE PROC ProcName

    @Param1 varchar(50) = null,

    @Param2 int = null

    AS

    SELECT field1, field2

    FROM tablename

    WHERE field1 = isnull(@Param1, field1)

    AND field2 = isnull(@Param2, field2)

     

    Summary: If you pass the parameter, it's used for the comparison.  If not, the field is compared against itself. Very simple, very easy to use.