none
How to merge tow column into column use sql server ?

    Question

  • example :

    Before:           columns                  columns                         After Merge:  columns_Merge

                           A         DA            B             DB                               AB                  TD         

                          jon         B1           jad            A1                              jonjad             B1A1

                          Null       Null           als            A2                                als                  A2

    please help !!

    • Edited by srajmuneer Tuesday, October 29, 2013 5:38 PM
    Tuesday, October 29, 2013 5:25 PM

Answers

  •  SELECT ISNULL(A,'')+ISNULL(B,'') as AB,
    ISNULL(DA,'')+ISNULL(DB,'') as TD 
    FROM yourtable             

    • Proposed as answer by Visakh16MVP Tuesday, October 29, 2013 6:22 PM
    • Marked as answer by srajmuneer Tuesday, October 29, 2013 7:02 PM
    Tuesday, October 29, 2013 6:21 PM
    Moderator
  • Select IsNull(A, '') + IsNull(B, '') As AB,
      IsNull('DA', '') + IsNull(DB, '') As TD
    From YourTableName

    Tom
    • Marked as answer by srajmuneer Tuesday, October 29, 2013 7:02 PM
    Tuesday, October 29, 2013 6:21 PM
  • update [table_1] 
    set A =ISNULL(A,'')+ISNULL(B,'')
    , DA =ISNULL(DA,'')+ISNULL(DB,'')
    Select A,DA from [table_1] 

    Please provide your table DDL.

    • Marked as answer by srajmuneer Tuesday, October 29, 2013 7:02 PM
    Tuesday, October 29, 2013 6:48 PM
    Moderator

All replies

  • Hi,

    It's difficult to follow with the formatting, but you just want to concatenate the fields??

    SELECT A + B, DA + DB FROM MYTABLE;


    Thanks, Andrew
    My blog...

    Tuesday, October 29, 2013 5:40 PM
  •  SELECT ISNULL(A,'')+ISNULL(B,'') as AB,
    ISNULL(DA,'')+ISNULL(DB,'') as TD 
    FROM yourtable             

    • Proposed as answer by Visakh16MVP Tuesday, October 29, 2013 6:22 PM
    • Marked as answer by srajmuneer Tuesday, October 29, 2013 7:02 PM
    Tuesday, October 29, 2013 6:21 PM
    Moderator
  • Select IsNull(A, '') + IsNull(B, '') As AB,
      IsNull('DA', '') + IsNull(DB, '') As TD
    From YourTableName

    Tom
    • Marked as answer by srajmuneer Tuesday, October 29, 2013 7:02 PM
    Tuesday, October 29, 2013 6:21 PM
  • I'am use : update [table_1] set [my column after merge] = A + B, DA + DB 

    but , when DA = NULL and DB = A2 /I'am show result TD = NULL  !!!!!

    Tuesday, October 29, 2013 6:27 PM
  • update [table_1] 
    set A =ISNULL(A,'')+ISNULL(B,'')
    , DA =ISNULL(DA,'')+ISNULL(DB,'')
    Select A,DA from [table_1] 

    Please provide your table DDL.

    • Marked as answer by srajmuneer Tuesday, October 29, 2013 7:02 PM
    Tuesday, October 29, 2013 6:48 PM
    Moderator