SELECT * FROM coAudit WHERE (@tiUserid = 0 OR tiUserid = userid) AND (@tcAction = 'ALL' OR actiontype = @tcAction)