October 18, 2010 at 5:09 am
in a column datatype in nvarchar
how can i detect if the string contains any double-byte character such as Chinese, Japanese or Korean?
Thanks~
October 18, 2010 at 5:13 am
Sounds like you need to use some ANSI searches to find those. What's your collation set as, BTW?
October 18, 2010 at 6:05 am
You could try comparing the nvarchar string to the string cast as varchar.
DECLARE @str1 nvarchar(20)
,@str2 nvarchar(20)
SELECT @str1 = N'AB' + NCHAR(12354) + N'CD'
,@str2 = N'ABCD'
IF @str1 <> CAST(@str1 AS varchar(20))
PRINT 'Str1 contains unicode character'
ELSE
PRINT 'Str1 contains no unicode'
IF @str2 <> CAST(@str2 AS varchar(20))
PRINT 'Str2 contains unicode character'
ELSE
PRINT 'Str2 contains no unicode'
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy