Collections:
Converting Binary Strings into Integers in SQL Server
How To Convert Binary Strings into Integers in SQL Server Transact-SQL?
✍: FYIcenter.com
Binary strings and integers are convertible implicitly and explicitly. But there several rules you need to remember:
Examples showing in the tutorial exercise below will help you remembering those rules.
SELECT 0x66 + 44 GO 146 DECLARE @integer INT; SET @integer = 0x66; SELECT @integer + 44 GO 146 SELECT CAST(0x66 AS INT) + 44 GO 146 SELECT CONVERT(INT, 0x66) + 44 GO 146 -- Only last 4 bytes are used for INT conversion SELECT 0x7700000066 + 44 GO 146 -- 8 bytes will be used for BIGINT conversion SELECT 0x7700000066 + CONVERT(BIGINT,44) GO 511101108370 -- 0x00 padded on the left hand side SELECT 0x66 + 44 SELECT 0x00000066 + 44 GO 146 146
⇒Character Strings and Binary Strings in SQL Server Transact-SQL
2017-02-28, 801👍, 0💬
Popular Posts:
How to download and install SQL Server 2005 Sample Scripts in SQL Server? If you want to learn from ...
What Is the Difference Between GETDATE() and GETUTCDATE() in SQL Server Transact-SQL? The difference...
How To Convert Numeric Expression Data Types using the CAST() Function in SQL Server Transact-SQL? I...
What Is a Parameter File in Oracle? A parameter file is a file that contains a list of initializatio...
Where to find answers to frequently asked questions on SQL Transaction Management in Oracle? Here is...