Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 concatenating local variables sql

Author  Topic 

dcummiskey
Starting Member

26 Posts

Posted - 2004-08-16 : 17:14:09
Hello -
I'm trying to build a string and I'm running into an issue combining a varchar. In a while statement I try to build the variable @key but i just get a NULL returned when its complete. I put a cast in there just to see if maybe both @key and the substring needed to be the same length...

Here's the line that does the concatenation...
set @key = @key + CAST(SUBSTRING(@alpha,@i, 1) as varchar(16))

Can you see what I'm doing wrong?

tnx.
Dan

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-08-16 : 17:19:16
You are probably trying to concatenate a NULL into the string and the CONCAT_NULL_YIELDS_NULL setting is ON.

Try this:

SET CONCAT_NULL_YIELDS_NULL OFF

your code goes here

Tara
Go to Top of Page

dcummiskey
Starting Member

26 Posts

Posted - 2004-08-16 : 17:33:18
That was it. Thanks.

- Dan
Go to Top of Page
   

- Advertisement -