Reply to Re: Stupid Question: Joining Strings

Your name:

Reply:


Posted by Roy Harvey on 01/21/07 00:14

The problem is that NULL concatenated with NULL results in NULL. So
unless @list is initialized with something it will always remain NULL
no matter how many things care concatenated on.

declare @list varchar(20)
set @list = @list + 'banana'
select @list

set @list = ''
set @list = @list + 'banana'
select @list

--------------------
NULL

--------------------
banana

As you see, even ititilizing it to an empty string is enough.

Roy Harvey
Beacon Falls, CT

On 20 Jan 2007 14:06:47 -0800, lee@digital-interactive.com wrote:

>Hi
>
>This is a dumb question as I know it's fairly easy but I cant seem to
>find an example after two hours of searching.
>
>In a stored procedure I'm trying to build up a string eg,
>
>(the following is in a loop)
>
>IF @xcount > 0
>BEGIN
> Set @list = @list + @title + ': ' + @xcount
>END
>
>Problem is when I come to return @list, it's always NULL - when I know
>there should be data returned. Any ideas?
>
>Thanks
>Lee

[Back to original 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

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