What are you doing with the result then? If this is a VB or ASP.NET app then its easy to read results into a string. However if you want to have a direct Expr in SQL statement then your way is a possibility. But perhaprs something could be done with Aliases?
@mike55:
If you dont need the columns separated out for any reasons, Id do it just the way you are, using + or whatever your DB uses for concatenation. You may want/need to wrap each column in case the values are null. In most databases, if you try to concatenate 2 strings and one is null, the result is null.
In SQL Server it would look like this:
Code:
SELECT IsNull(column1, ) + , + IsNull(column2, ) + , + IsNull(column3, ) as Exp1
FROM Table1
You can also use COALESCE (maybe with 2 Ls?) instead of IsNull if you prefer.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.