• Dave,

    Thanks for the link. Some good stuff when thinking about dynamic SQL. I started down the dynamic path and was breaking apart the code and realized that I had an error in the WHERE clause. I get myself in more trouble with cut/paste.

    I was checking if the passed parameter was NULL not the field. I should of had:

    select * from #mytable

    WHERE (eq_id = @eq_id or eq_id IS NULL) AND (bl_id = @bl_id or bl_id IS NULL)

    AND (fl_id = @fl_id or fl_id IS NULL) AND (rm_id = @rm_id or rm_id IS NULL)

    I am pretty sure this is giving me what I need.

    Sometimes just asking the question gets things going.

    Thanks,

    Craig