0

I have string in format:

8:live:avishekh.bh 8:prakash.tndk 8:niraj.bajra

I want these in the format :

[live:avishekh.bh, prakash.tndk, niraj.bajra]

How could I achieve that in SQLServer?

2 Answers 2

2

You can use combination of stuff and replace:DEMO HERE

declare @string varchar(100)='8:live:avishekh.bh 8:prakash.tndk 8:niraj.bajra'

     select 
        '['+
        stuff(
        replace(@string,'8:',','),1,1,'')+']'
Sign up to request clarification or add additional context in comments.

Comments

1

this should work

SELECT 
QUOTENAME(STUFF(REPLACE('8:live:avishekh.bh 8:prakash.tndk 8:niraj.bajra','8:',','),1,1,''))

QUOTENAME function is used for inserting square bracket in sql server

Comments

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.