Using A Coalesce Function in a Where in Clause

  • hi all i am testing a query which is defined like this

    declare @id varchar(30)

    declare @lastname varchar(30)

    declare @jobs varchar(30)

    SET @id = '('1','2')'

    SET @jobs = null

    SET @lastname = NULL

    SELECT idcol,

    jobscol,

    lastnamecol

    FROM tbl_profile

    WHERE idcol in (COALESCE('1,2',idcol))

    AND

    lastnamecol = COALESCE(@lastname,lastnamecol) AND

    jobscol = COALESCE(@jobs,jobscol)

    is the COALESCE function possible for where IN Clause statements

    thanks

  • Please don't cross post. It wastes people's time and fragments replies. I answered your other post.

    Replies to the following thread please - How to do Coalesce

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply