You are here: Re: Select several values into a single variable « MsSQL Server « IT news, forums, messages
Re: Select several values into a single variable

Posted by Hugo Kornelis on 10/02/16 11:47

On Thu, 11 May 2006 12:35:11 +0000 (UTC), Erland Sommarskog wrote:

>Malc (M.B.Pinfold@massey.ac.nz) writes:
>> Can somebody please tell me whether the following syntax is supported
>> or whether it's a "feature" that will someday stop working. It works in
>> both SQL Server 2000 and 2005 at the moment.
>>
>> declare @var varchar(1000)
>> set @var = ''
>> select @var = @var + colx from some_table where col1 = some_value
>
>The correct result of this operation is undefined. You may get a
>concatenated list, or only a single value.
>
>I recommend against using this.
>
>There is a supported way to do this on SQL 2005 with help of FOR XML PATH.
>Unfortunately, I have the sample code at home only, so I cannot post it.

Hi Erland and Malc,

Tony Rogerson featured the FOR XML PATH method of concatenating in his
blog entry of today:


http://sqlserverfaq.com/blogs/blogs/tonyrogerson/archive/2006/05/11/429.aspx

--
Hugo Kornelis, SQL Server MVP

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация