| | |
HELP!!! Converting Hexadecimal to Decimal or vice versa
Please support our MS SQL advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2009
Posts: 4
Reputation:
Solved Threads: 0
I'm in the process of converting two columns in two separate tables...
One column in Table A has a hexadecimal number (with a nvarchar data type) i.e. "A5000000020" and converting it to a decimal it should be "11338713661472"...
In Table B the column has a decimal number (with a bigint data type) i.e "1434519076864" and converting it to a hexadecimal the would make the value "9D500000005"
I keep getting stuck!!!
How can I successfully convert these columns?!
Thanks in advance!!!
One column in Table A has a hexadecimal number (with a nvarchar data type) i.e. "A5000000020" and converting it to a decimal it should be "11338713661472"...
In Table B the column has a decimal number (with a bigint data type) i.e "1434519076864" and converting it to a hexadecimal the would make the value "9D500000005"
I keep getting stuck!!!
How can I successfully convert these columns?!
Thanks in advance!!!
sql Syntax (Toggle Plain Text)
CREATE PROCEDURE Stp_HexToInt @HexValue VARCHAR(20) AS BEGIN DECLARE @Query nvarchar(100) DECLARE @Parameters nvarchar(50) DECLARE @ReturnValue INT if (charindex('0x',@HexValue) = 0) SET @HexValue = '0x' + @HexValue SET @Query = N'Select @Result = Convert(int,' + @HexValue + ')' SET @Parameters = N'@Result int output' Exec master.dbo.Sp_executesql @Query, @Parameters, @ReturnValue Output RETURN @ReturnValue END
Taken from: http://www.codeproject.com/KB/databa...tUsingSQL.aspx
For going the other way:
http://snippets.dzone.com/posts/show/707
![]() |
Similar Threads
- How to convert Image into binary file and vice-versa (Java)
- Convert a word in kanji to katakana or vice-versa. (VB.NET)
- 2D array to 1D array vice versa?? (VB.NET)
- Converting ASCII to Decimal (Assembly)
- Web Service in PHPٌ (PHP)
- Convert double from Small Endian to Big Endian and vice versa (C#)
- convert lower case letters to uppercase and vice-versa (C++)
- 1 .Exporting data from Dataset to XLl sheet in VB.net Windows Application &vice versa (VB.NET)
- Converting byte value into integer and vice versa (C++)
Other Threads in the MS SQL Forum
- Previous Thread: Search/Replace
- Next Thread: Query database to see if value already exists one statment
| Thread Tools | Search this Thread |






