• It is a little confusing what you're asking for, but based on your topic title ("adding dynamic sql") and looks like you are trying to build a dynamic where clause. Perhaps try something like this:

    AND (@xid='A' AND value= 1)

    OR (@xid='B' AND value = 2)

    OR (@xid='C' AND value = 3

    AND (@jid = 100)))

    For each parameter that evaluates as true, it will evaluate the other half of the AND statement. So, if 'A' is chosen the value will be 1, etc.

    HTH