Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
smithje
Starting Member
32 Posts |
Posted - 2006-04-14 : 17:45:38
|
| I need to convert hex data to its real value. Typed directly into the Query Analyzer it works fine [ SELECT CONVERT(INT, 0X0F425B) ]returns 1000027. SQL does require the 0X be added in front.The problem comes when I try to pass a query result into the formula by concatanation of the 0x and the known hex values. SQL insist on seeing the concatanated value as a text string and gives the error:Syntax error converting the varchar value '0X0F425B' to a column of data type int. I have tried converting the data to sql_variant and have changed the concatanation process to use CHAR(48) and CHAR(88) but it still sees it as text and will not convert it. Anybody done this? Know how?Thanks |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-04-14 : 18:37:43
|
| declare @s varchar(20)select @s = '0F425B'declare @i intdeclare @sql nvarchar(200)select @sql = 'select @i = 0x' + @sexec sp_executesql @sql, N'@i int out', @i outselect @i==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
smithje
Starting Member
32 Posts |
Posted - 2006-04-14 : 18:44:32
|
| I see it working but it will take some study for me to get this. Thanks. |
 |
|
|
|
|
|