SQL 2012 - XML Question

garywin7garywin7 Member Posts: 21 ■□□□□□□□□□

I may be remembering this wrong but

is there a way of outputting :-


so combining 2 columns into one element ?

if this is nonsense then just let me know , no need to swear though . . .



  • NotHackingYouNotHackingYou Member Posts: 1,460 ■■■■■■■■□□
    If the columns are non XML columns then you can use simple concatenation. SELECT '<name>' + firstName + '/' + lastName + '</name>' FROM usersTable WHERE (conditions). This will output in the format you want. There are other ways to do this but this is quick.

    If you are trying to extract from an XML column then it is a little tricker.
    When you go the extra mile, there's no traffic.
  • garywin7garywin7 Member Posts: 21 ■□□□□□□□□□

    I'm thinking of non-xml columns so I know you can use FOR XML AUTO etc.
    and its that type of answer i'm really looking for

    good idea on the select string approach though
Sign In or Register to comment.