Reputation: 9
Have to concatenate sql query result With some strings. I am getting sql query result like this
+--------------------+
| Some Value |
+--------------------+
|abc,xyz,amar,akbar |
+--------------------+
| hjk,fed,fas |
| |
+--------------------+
I want to concatenate ' with each row result like this and I am using Sql server 2012.
+--------------------------+
| Some Value |
+--------------------------+
|'abc','xyz','amar','akbar'|
+--------------------------+
| 'hjk','fed','fas' |
| |
+--------------------------+
Please help me..
Upvotes: 1
Views: 194
Reputation: 31879
You can add a '
on the start and end of your string. Then REPLACE
,
with ','
:
SELECT '''' + REPLACE(some_value, ',', ''',''') + '''' FROM tbl
Upvotes: 1