|
Home >> FAQs/Tutorials >> SQL Server FAQ
SQL Server FAQ - Concatenating Two Binary Strings
By: FYIcenter.com
(Continued from previous topic...)
How To Concatenate Two Binary Strings Together?
SQL Server 2005 allows to concatenate two binary strings into a single string with
the (+) operator. The following tutorial exercise shows you some binary string concatenation examples:
-- Concatenating two binary string literals
SELECT 0x57656C636F6D6520746F20
+ 0x46594963656E7465722E636F6D;
GO
0x57656C636F6D6520746F2046594963656E7465722E636F6D
-- Watch out: This is not a binary string concatenation
SELECT '0x57656C636F6D6520746F20'
+ '0x46594963656E7465722E636F6D';
GO
0x57656C636F6D6520746F200x46594963656E7465722E636F6D
-- Concatenating two binary strings
SELECT CONVERT(VARBINARY(40),'Welcome to ')
+ CONVERT(VARBINARY(40),'FYIcenter.com');
GO
0x57656C636F6D6520746F2046594963656E7465722E636F6D
-- Binary strings can not be concatenated
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.
(Continued on next topic...)
- How To Concatenate Two Character Strings Together?
- What Happens When Unicode Strings Concatenate with Non-Unicode Strings?
- How To Convert a Unicode Strings to Non-Unicode Strings?
- What Are the Character String Functions Supported by SQL Server 2005?
- How To Insert New Line Characters into Strings?
- How To Locate and Take Substrings with CHARINDEX() and SUBSTRING() Functions?
- How To Concatenate Two Binary Strings Together?
- Can Binary Strings Be Used in Arithmetical Operations?
- How To Convert Binary Strings into Integers?
- Can Binary Strings Be Converted into NUMERIC or FLOAT Data Types?
- Can Binary Strings Be Converted into Character Strings?
- Can Binary Strings Be Converted into Unicode Character Strings?
- How To Convert Binary Strings into Hexadecimal Character Strings
- What Are Bitwise Operations?
|