1

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..

1

1 Answer 1

1

You can add a ' on the start and end of your string. Then REPLACE , with ',':

SQL Fiddle

SELECT '''' + REPLACE(some_value, ',', ''',''') + '''' FROM tbl
Sign up to request clarification or add additional context in comments.

1 Comment

thanks ...Felix Pamittan

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.