How to check Table Column In like

  • I wan to check Table Column in where Clause like where Table.Column like 'Table.Column%'

  • Can you please elaborate. Always remember to include DDL, sample data and expected result in your posts, so that others can clearly understand your issue.



    Ole Kristian Velstadbråten Bangås - Virinco - Facebook - Twitter

    Concatenating Row Values in Transact-SQL[/url]

  • Check Query That I tried

    DECLARE @CFR as Table

    (CFRCode varchar(50),

    CFR_MATCH Varchar(10),

    CFR_COMM_CODE varchar(50),

    CFR_COMM_DESC varchar(250),

    Final_DEsc varchar(300))

    DECLARE @CFR_SAVVION as Table

    (CFRCode varchar(50),

    CFR_COMM_CODE varchar(50),

    COMMENT varchar(250))

    INSERT INTO @CFR_SAVVION

    SELECt 'C09','C11','Q no ...to be answered by advisor/SM/BM'

    UNION ALL

    SELECt 'C09','C12','Q no ...to be clarified by advisor/SM/BM'

    UNION ALL

    SELECt 'C09','C13','Signature, date & place required by SM / BM / BDM / AM / RM'

    UNION ALL

    SELECt 'M07','C135','Child MER'

    UNION ALL

    SELECt 'M07','C183','Level 2'

    INSERT INTO @CFR

    SELECt 'C09','RIGHTLIKE','C11','to be answered by advisor/SM/BM','No Change'

    UNION ALL

    SELECt 'C09','RIGHTLIKE','C12','to be clarified by advisor/SM/BM','No Change'

    UNION ALL

    SELECt 'C09','EQUAL','C13','Signature, date & place required by SM / BM / BDM / AM / RM','No Change'

    UNION ALL

    SELECt 'M07','LEFTTLIKE','C135','Child MER','CFR + [medical test(s)] to be done from the companys''s empanelled center.'

    UNION ALL

    SELECt 'M07','LEFTTLIKE','C183','Level 2','CFR + [medical test(s)] to be done from the company''s empanelled center.'

    UNION ALL

    SELECt 'M07','LEFTTLIKE','C182','Level 1','CFR + [medical test(s)] to be done from the company ''s empanelled center.'

    SELECT * FROM @CFR

    Select * from @CFR_SAVVION

    -- Select 'LIKE' + ' '+ '''' + CFR_COMM_DESC + '%''' from @CFR

    SELECT DISTINCT

    CASE WHEN CF.CFR_MATCH='RIGHTLIKE' THEN

    (CASE WHEN SV.CFRCode=CF.CFRCode AND SV.CFR_COMM_CODE=CF.CFR_COMM_CODE

    AND SV.COMMENT LIKE + '''%' + CF.CFR_COMM_DESC

    THEN CF.Final_DEsc END)

    WHEN CF.CFR_MATCH='EQUAL' THEN

    (CASE WHEN SV.CFRCode=CF.CFRCode AND SV.CFR_COMM_CODE=CF.CFR_COMM_CODE AND SV.COMMENT = CF.CFR_COMM_DESC THEN CF.Final_DEsc END)

    WHEN CF.CFR_MATCH='LEFTTLIKE' THEN

    (CASE WHEN SV.CFRCode=CF.CFRCode AND SV.CFR_COMM_CODE=CF.CFR_COMM_CODE

    AND SV.COMMENT LIKE CF.CFR_COMM_DESC + '%'''

    THEN CF.Final_DEsc END)

    END AS CFR_FINAL

    from @CFR_SAVVION SV INNER JOIN @CFR CF

    ON SV.CFR_COMM_CODE=CF.CFR_COMM_CODE

  • Try changing the '%''' and '''%' in your code to '%'

    That should probably make it work..


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • Thanks Kingston Dhasian

    Its work.....:hehe:

Viewing 5 posts - 1 through 4 (of 4 total)

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