ar_ogsys
October 12th, 2005, 01:36 PM
Hey,
I'm trying to concatenate query results into a char variable, but for some reason the query results won't concatenate. For example:
DECLARE @COMP CHAR(12)
DECLARE @COMP2 char(12)
DECLARE @COMP3 char(12)
SET @COMP3 = (SELECT Code FROM Company CO WHERE CO.Code = 3)
SET @COMP2 = (SELECT Code FROM Company CO WHERE CO.Code = 2)
PRINT @COMP3
PRINT @COMP2
SET @COMP = @COMP2 + @COMP3
PRINT @COMPWhere CO.Code is also char(12). The output looks like:
3
2
2
Are the select statements putting NULLs around my variables? If so, is there a way to clean the data/variables?
Or is there some other reason this code won't concatenate?
I'm using SQL Server and SQL Query Analyzer.
Thanks for any help!
I'm trying to concatenate query results into a char variable, but for some reason the query results won't concatenate. For example:
DECLARE @COMP CHAR(12)
DECLARE @COMP2 char(12)
DECLARE @COMP3 char(12)
SET @COMP3 = (SELECT Code FROM Company CO WHERE CO.Code = 3)
SET @COMP2 = (SELECT Code FROM Company CO WHERE CO.Code = 2)
PRINT @COMP3
PRINT @COMP2
SET @COMP = @COMP2 + @COMP3
PRINT @COMPWhere CO.Code is also char(12). The output looks like:
3
2
2
Are the select statements putting NULLs around my variables? If so, is there a way to clean the data/variables?
Or is there some other reason this code won't concatenate?
I'm using SQL Server and SQL Query Analyzer.
Thanks for any help!