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,
le*@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