0

In Sql server, I want to convert a string 'EN,ES,FR'to ISNULL('EN','') + ISNULL('FR','') + ISNULL('ES',''). What is the easiest way to do that. Thanks in advance.

2
  • Why not use coalesce instead? coalesce(EN,ES,FR) Or are you trying concatenate all these column values together? Commented Feb 24, 2017 at 22:35
  • I don't understand your question. Commented Feb 24, 2017 at 22:45

1 Answer 1

2

Is this what you mean?

declare @list nvarchar(20)
set @list = 'EN,FR,ES'
print 'ISNULL(''' + replace(@list, ',', ''','''') + ISNULL(''') + ''','''')'

Output is

ISNULL('EN','') + ISNULL('FR','') + ISNULL('ES','')

...or have I got completely the wrong end of the stick?!

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, this is what I was looking for. Thanks

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.