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.
-
Why not use coalesce instead? coalesce(EN,ES,FR) Or are you trying concatenate all these column values together?Sean Lange– Sean Lange2017-02-24 22:35:12 +00:00Commented Feb 24, 2017 at 22:35
-
I don't understand your question.hatchet - done with SOverflow– hatchet - done with SOverflow2017-02-24 22:45:47 +00:00Commented Feb 24, 2017 at 22:45
Add a comment
|
1 Answer
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?!
1 Comment
Mike143
Yes, this is what I was looking for. Thanks