Collections:
Converting Unicode Strings to Non-Unicode Strings in SQL Server
How To Convert a Unicode Strings to Non-Unicode Strings in SQL Server Transact-SQL?
✍: FYIcenter.com
Since Unicode character set is different than code page based (non-Unicode) character set, converting Unicode strings to non-Unicode strings may result in wrong characters or missing characters. So you should avoid converting Unicode strings to non-Unicode strings.
If you really want to, there are 3 ways to convert a Unicode string to a non-Unicode string:
Some numeric data type conversion examples are provided in the tutorial exercise below:
-- Implicit conversion by an assignment operation DECLARE @regcode VARCHAR(40); SET @regcode = N'Some Unicode characters: ' + NCHAR(9733)+NCHAR(9734)+NCHAR(9792)+NCHAR(9794); SELECT @regcode; GO Some Unicode characters: ???? -- Explicit conversion by CAST() SELECT CAST(N'Some Unicode characters: ' + NCHAR(9733)+NCHAR(9734)+NCHAR(9792)+NCHAR(9794) AS VARCHAR(40)); GO Some Unicode characters: ???? -- Explicit conversion by CONVERT() SELECT CONVERT(VARCHAR(40), N'Some Unicode characters: ' + NCHAR(9733)+NCHAR(9734)+NCHAR(9792)+NCHAR(9794)); GO Some Unicode characters: ????
⇒ Character String Functions Supported by SQL Server 2005 in SQL Server
⇐ String Type Conversion During Concatenation in SQL Server
⇑ Character Strings and Binary Strings in SQL Server Transact-SQL
2017-03-07, 3801🔥, 0💬
Popular Posts:
What Are the Underflow and Overflow Behaviors on FLOAT Literals in SQL Server Transact-SQL? If you e...
How To Create a Dynamic Cursor with the DYNAMIC Option in SQL Server Transact-SQL? If the underlying...
What Is the Difference Between GETDATE() and GETUTCDATE() in SQL Server Transact-SQL? The difference...
Where to find tutorials to answer some frequently asked questions on Microsoft SQL Server Transact-S...
What Happens to Your Transactions When ERROR 1213 Occurred in MySQL? If your transaction receives th...