473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Stupid Question: Joining Strings

lee
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

Jan 20 '07 #1
1 2878
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
Jan 21 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Carlos Ribeiro | last post by:
As a side track of my latest investigations, I began to rely heavily on generators for some stuff where I would previsouly use a more conventional approach. Whenever I need to process a list, I'm...
3
by: snacktime | last post by:
The primary question is how do I perform a match when the regular expression contains string variables? For example, in the following code I want to match a line that starts with STX, then has any...
1
by: Joe | last post by:
I've got 3 columns in a mysql database that I am trying to join. I'm using CONCAT(), but it's giving me NULL results. This has worked for me before ... What am I doing wrong? Here's a straight...
5
by: John Baro | last post by:
I have a richtextbox which I want the "literal" rtf of. richtextbox.rtf returns {\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033\\uc1 }\r\n\0 when i put this into a string I get...
6
by: mike | last post by:
Is it possible to to the following I have tables which are updated via webpage (perl) with fields of type int and date (all nullable). If the values are blank the entire insert fails, with a...
6
by: Adam Smith | last post by:
I have posted this and similar questions repeatedly and can't even raise a single response. I am being led to believe that this then 'Must be a stupid question' although people say that there is no...
1
by: antjudy01 | last post by:
Hi, I was thinking about joining the MSFT Empower program which includes "5 licenses to Visual Studio 2005 Professional Edition". My question is how do I get the media to actually install the...
1
by: google1 | last post by:
Has anyone written this one? Seen such a thing? Please send me a link: Skill Testing Question Exploder --------------------------------------------- Basically the plan is to create the...
13
by: SUBHABRATA | last post by:
Dear Group, I am trying the following code line: def try2(n): a1=raw_input("PRINT A STRING:") a2=a1.split() a3="God Godess Heaven Sky" for x in a2: a4=a3.find(x) if a4>-1: a5=a3
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.