andrishelp
asked on
SQL server - SELECT Query to concat the few columns
SELECT col1, col2,col3,col4,col5 FROM tablename
All columns data type are integer
I wrote this following statement, but any of the column has NULL value, I get empty string which is incorrect result.
SELECT (convert(nvarchar(10),col1 ) + ',' +convert(nvarchar(10),col2 )+ ',' +convert(nvarchar(10),col3 )+ ',' +convert(nvarchar(10),col4 )+ ',' +convert(nvarchar(10),col5 )) as colstring FROM tablename
How to concat all columns and make it one string? If any of the column value is NULL, do not include that?
Thanks,
All columns data type are integer
I wrote this following statement, but any of the column has NULL value, I get empty string which is incorrect result.
SELECT (convert(nvarchar(10),col1
How to concat all columns and make it one string? If any of the column value is NULL, do not include that?
Thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.