I have a table in SQL Server that looks like this
Value First Last Email Phone ----------------------------------------------------- 1 Smith CLEO some@yahoo.com 123456774
If this table was in Oracle and I wanted to get all the properties separated by different separators then I would write something like this
Select Value ||','|| First ||'!'|| Last ||'?'|| Email ||'~'|| Phone from user_table;
I would get output like this
1,Smith!CLEO?some@yahoo.com~123456774
Notice all the separators are different. How can I write a similar select statement for SQL Server?
Advertisement
Answer
You can use concat()
:
Select concat(Value, ',', First , '!', Last, '?', Email, '~', Phone) from user_table;