﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / T-SQL (SS2K8)  / Is this a bug ??? / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Fri, 24 May 2013 07:39:19 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Is this a bug ???</title><link>http://www.sqlservercentral.com/Forums/Topic1381927-392-1.aspx</link><description>If you want to generate a list of values from a column of values, like this, your best bet is to use For XML Path to do the work for you.Bing/Google/whatever "concatenate string sql server for xml" or "sql server for xml path", and you'll find articles and tutorials on how to do this.  It's very fast, effective, and quite a neat trick.</description><pubDate>Wed, 07 Nov 2012 06:27:36 GMT</pubDate><dc:creator>GSquared</dc:creator></item><item><title>RE: Is this a bug ???</title><link>http://www.sqlservercentral.com/Forums/Topic1381927-392-1.aspx</link><description>ok......Got it  thanks....:-)</description><pubDate>Wed, 07 Nov 2012 06:05:34 GMT</pubDate><dc:creator>Saurv</dc:creator></item><item><title>RE: Is this a bug ???</title><link>http://www.sqlservercentral.com/Forums/Topic1381927-392-1.aspx</link><description>It's not a bug. The syntax you are using is never reliable to get string concatenation in T-SQL. BTW, Order By 1 in your first sample, is not inequivalent to Order By seq... It is equal to [code="sql"]order by @comma_Delimited + k + ',' [/code] </description><pubDate>Wed, 07 Nov 2012 06:02:07 GMT</pubDate><dc:creator>Eugene Elutin</dc:creator></item><item><title>Is this a bug ???</title><link>http://www.sqlservercentral.com/Forums/Topic1381927-392-1.aspx</link><description>why is the difference between both outputs ...--SQL1: Declare @tab table (seq int , k varchar(20))declare @comma_Delimited varchar(max)set @comma_delimited=''insert into @tabselect 1,'s'union allselect 2,'K'union allselect 3,'t'union allselect 4,'l'select  @comma_Delimited =@comma_Delimited +  k + ','  from @tab order by 1select @comma_Delimited--SQL2.Declare @tab table (seq int , k varchar(20))declare @comma_Delimited varchar(max)set @comma_delimited=''insert into @tabselect 1,'s'union allselect 2,'K'union allselect 3,'t'union allselect 4,'l'select  @comma_Delimited =@comma_Delimited +  k + ','  from @tab order by seqselect @comma_DelimitedWhy "Order by 1" is creating difference ...?</description><pubDate>Wed, 07 Nov 2012 05:51:41 GMT</pubDate><dc:creator>Saurv</dc:creator></item></channel></rss>