Calling three column in to one column in the grid

Jawab Calling three column in to one column in the grid

  • 13 Maret 2012 8:21
     
     

    i tried with plus mark its working ,

    but if there is any null value in the database column its shows null for other two values

    ex: BankName+SuplierName+Customer AS CusDetail 

    If BankName= BOC , SuplierName = NULL & Customer= NULL

    all the columns are showing null

    like thsis

    CusDetail

    ------------

    Null

    Null

    Null

    i there any solution for this???

Semua Balasan

  • 13 Maret 2012 8:24
    Penjawab Pertanyaan
     
     Jawab

    Use COALESCE to eliminate NULLs

    SELECT COALESCE(BankName,'unknown')+COALESCE(SuplierName,'unknown')+COALESCE(Customer,,'unknown')

    FROM tbl


    Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/

    • Disarankan sebagai Jawaban oleh Tiya01 13 Maret 2012 8:37
    • Ditandai sebagai Jawaban oleh Ahmed Malik 13 Maret 2012 8:50
    •