Help in a query to get result


  • Hi, A value is null in code_b field thats why result of this row getting Null. How I can get get actual data in a result.

    create table #A  (code_a char(10), code_b char(10), code_c char(10))

    insert into #A values ('12345',Null,'ABC')

    insert into #A values ('55555','999999999','ABCD')

    Select code_a +cast('' as char(1))+

    cast(code_b as char(9)) +

    cast(code_c as char(9)) from #A



    55555 999999999

    --Exptected Result

    12345  Null    ABC

    55555 999999999ABCD

    Wednesday, June 13, 2012 3:08 AM


  • Select code_a +cast('' as char(1))+

    isnull(cast(code_b as char(9)),'Null') +

    cast(code_c as char(9)) from #A

    Many Thanks & Best Regards, Hua Min

    • Marked as answer by Kenny_Gua Wednesday, June 13, 2012 3:13 AM
    Wednesday, June 13, 2012 3:10 AM

All replies