Reputation: 43636
I have a function that converts CSV list to nvarchar(max) records in table. I have noticed it is not working with cyrillic and the problem is this replace here:
DECLARE @XML xml = N'<r><![CDATA[' + REPLACE(@List, ',', ']]></r><r><![CDATA[') + ']]></r>'
How to make the replace to work with cyrillic symbols? For example 'тест'.
@List is NVARCHAR(MAX) and I am using SQL Server 2012.
Upvotes: 0
Views: 2450
Reputation: 37215
The N''
notation is used to declare Unicode string literals. If you define a variable NVARCHAR, it is automatically Unicode-enabled (so there is no need (or rather: no way) to additionally declare the N
for @variables - it is part of the string literal).
Since you get Cyrillic characters in SELECT N'тест'
, you should check where the variable @List is assigned, and what it's value is.
Not sure how your CSV parser handles Unicode characters, but the source of your problem may be
Upvotes: 1
Reputation: 51494
Are you defining your @List
variable as nvarchar? Replace will work fine with nvarchars
declare @list nvarchar(50) = N'те,ст'
select @list
DECLARE @XML xml = N'<r><![CDATA[' + REPLACE(@List, ',', ']]></r><r><![CDATA[') + ']]></r>'
Upvotes: 1