473,804 Members | 3,147 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2892
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
1954
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 tending towards the use of generators. One good example is if I want to print a report, or to work over a list with complex processing for each item. In both cases, a simple list comprehension can't be used. The conventional approach involves...
3
2528
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 number of characters, then ends with STX. Example 2 I'm pretty sure works as I expect, but I'm not sure about Example 1, and I'm pretty sure about example 3. import re from curses.ascii import STX,ETX,FS STX = chr(STX)
1
4989
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 select: mysql> select peopleID, firstName, middleInit, lastname -> from people; +----------+-----------+------------+------------+ | peopleID | firstName | middleInit | lastname |
5
3023
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 "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033\\uc1 }\r\n\0" I want this to be @"{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033\\uc1 }\r\n\0" to treat the escape characters as literals
6
1352
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 wrong type error. Is there any way to stop this behaviour so that the valid information is allowed,but the blank values get ignored. ---------------------------(end of broadcast)---------------------------
6
1620
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 stupid question. Is that another for political correctness I am attempting an install of 7.4.3 on FreeBSD O/S 4.9, apparently remnants of 7.3.x are scattered around on the disk from (a) previous ports installation, causing mutex_lock/unlock,...
1
1243
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 Visual Studo product? The Empower program comes with all sorts of licenses to different products, but I don't understand how I get the media to actually install the programs...
1
2157
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 javascript powered form one can surf to to bypass cheating via Window calculator for Skill Testing Question tests. One simply copys the Skill Testing Question from the Contest Webpage
13
1010
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
9708
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10588
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10324
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10085
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7623
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5662
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.