CREATE PROCEDURE ct_UserAuditListing @tiUserID int, @tcAction varchar(30) --tiUserID=0 we want all users --tcAction="ALL" we want all actions as select * from coAudit case when @tiUserid>0 and @tcAction='ALL' then where userid=@tiUserID when @tiUserID>0 then where userid=@tiUserID and actiontype=@tcAction when @tiUserID=0 and @tcAction<>'ALL' then where actiontype=@tcActionObviously, the code above doesn't work, but is there a way to make it work or do I have to make a seperate stored procedure for each flavor of the query