Developing Matt

My Technical Journal

Row Concatenation Tests

leave a comment »

I found an article by John Alexander Lopez in the october 07 edition of sql server mag.  He discussed how concatenating the normal way (with select statements) isn’t near as efficient as using the new ‘for xml’ method.  Here’s an example of how to use it

 declare @concattest varchar(max)

set @concattest = (select column1 + ‘,’ + column2 as [text()] from tblstores
for xml path(”))
select left(@concattest,len(@concattest)-1)

Advertisements

Written by matt

January 7, 2008 at 10:51 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: