Home
Certification Preparation
Microsoft
SQL Server exams
SQL 2012 - XML Question
garywin7
Hi
I may be remembering this wrong but
is there a way of outputting :-
<Name>Fred/Bloggs<Name>
so combining 2 columns into one element ?
if this is nonsense then just let me know , no need to swear though . . .
Find more posts tagged with
Comments
NotHackingYou
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.
garywin7
Hi
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
Quick Links
All Categories
Recent Posts
Activity
Unanswered
Groups
Best Of