Collections:
Converting Binary Strings into Character Strings in SQL Server
Can Binary Strings Be Converted into Character Strings in SQL Server Transact-SQL?
✍: FYIcenter.com
Binary strings and character strings are convertible. But there are several rules you need to remember:
For examples, see the tutorial exercise below:
-- Implicit conversion to character strings DECLARE @char_string VARCHAR(40); SET @char_string = 0x46594963656E7465722E636F6D; SELECT @char_string; GO FYIcenter.com -- Implicit conversion to binary strings DECLARE @binary_string VARBINARY(40); SET @binary_string = 'FYIcenter.com'; GO Msg 257, Level 16, State 3, Line 2 Implicit conversion from data type varchar to varbinary is not allowed. Use the CONVERT function to run this query. -- Explicit conversion to binary strings DECLARE @binary_string VARBINARY(40); SET @binary_string = CONVERT(VARBINARY(40),'FYIcenter.com'); SELECT @binary_string; GO 0x46594963656E7465722E636F6D -- Implicit conversion in concatenation operation with character strings SELECT 'Welcome to ' + 0x46594963656E7465722E636F6D; GO Msg 402, Level 16, State 1, Line 1 The data types varchar and varbinary are incompatible in the add operator.
⇒ Converting Binary Strings into Unicode Character Strings in SQL Server
⇐ Converting Binary Strings into NUMERIC or FLOAT in SQL Server
⇑ Character Strings and Binary Strings in SQL Server Transact-SQL
2017-02-28, 2080🔥, 0💬
Popular Posts:
What Are Bitwise Operations in SQL Server Transact-SQL? Bitwise operations are binary operations per...
How to continue to the next iteration of a WHILE loop in SQL Server Transact-SQL? How to use CONTINU...
How To Generate CREATE VIEW Script on an Existing View in SQL Server? If you want to know how an exi...
How To Recover a Dropped Index in Oracle? If you have the recycle bin feature turned on, dropped ind...
What Happens If the UPDATE Subquery Returns Multiple Rows in MySQL? If a subquery is used in a UPDAT...