Collections:
String Type Conversion During Concatenation in SQL Server
What Happens When Unicode Strings Concatenate with Non-Unicode Strings in SQL Server Transact-SQL?
✍: FYIcenter.com
If a Unicode string NVARCHAR is concatenated with a non-Unicode string VARCHAR, SQL Server will implicitly convert the non-Unicode string to Unicode string for concatenation.
DECLARE @regcode VARCHAR(40); DECLARE @unicode NVARCHAR(40); SET @regcode = 'Some Unicode characters: ' SET @unicode = NCHAR(9733)+NCHAR(9734)+NCHAR(9792) +NCHAR(9794); SELECT @regcode + @unicode; SELECT DATALENGTH(@regcode); SELECT DATALENGTH(@unicode); SELECT DATALENGTH(@regcode + @unicode); Some Unicode characters: ???? 25 8 58
Note that the non-Unicode string @regcode has been converted to a Unicode string. The number of bytes of @regcode changed from 25 to 50. With 8 bytes from @unicode, the number of bytes of the concatenated string becomes 58.
⇒ Converting Unicode Strings to Non-Unicode Strings in SQL Server
⇐ Concatenating Two Character Strings in SQL Server
⇑ Character Strings and Binary Strings in SQL Server Transact-SQL
2017-03-11, 1624🔥, 0💬
Popular Posts:
How To Use GO Command in "sqlcmd" in SQL Server? "sqlcmd" is a command line client application to ru...
How To Create a Dynamic Cursor with the DYNAMIC Option in SQL Server Transact-SQL? If the underlying...
What is dba.FYIcenter.com Website about? dba.FYIcenter.com is a Website for DBAs (database administr...
How REAL and FLOAT Literal Values Are Rounded in SQL Server Transact-SQL? By definition, FLOAT(n) sh...
How To End a Stored Procedure Properly in SQL Server Transact-SQL? Where the end of the "CREATE PROC...