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 |
|
avmreddy17
Posting Yak Master
180 Posts |
Posted - 2006-04-29 : 13:52:57
|
| Is there any function in SQL Server to convert INT Values to HEXEx IF Int Value = 33948700 ,then I shud get HEX Value = 206041CThx All for any helpVenu |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-04-29 : 15:27:05
|
| [code]select [HEX Int] = convert(varbinary(4),33948700)[/code]Results:[code]HEX Int ---------- 0x0206041C(1 row(s) affected)[/code]CODO ERGO SUM |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
avmreddy17
Posting Yak Master
180 Posts |
Posted - 2006-05-03 : 14:56:24
|
| How to get first four characters from the Varbinary fieldI have this column of varbinary type and its values is 0x24000001.I want to get 0x24 from the above value because I need to convert that to an integer.Any ideasThxVenu |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-05-03 : 16:10:09
|
| [code]select First_2 = substring(0x24000001,1,2)Results:First_2 ------- 0x2400(1 row(s) affected)[/code]CODO ERGO SUM |
 |
|
|
PSamsig
Constraint Violating Yak Guru
384 Posts |
Posted - 2006-05-04 : 01:40:16
|
| Please dont tell me you ended up storing your int in a varbinary field, Im pretty sure the suggestion for varbinary was only for presentation purposes. It is unwise to store it like that and even worse to do 'calculations´ on them like this afterwards.If you have an in with the value 0x24000001 (a.k.a. 603979777) then just devide it with 0x1000000 (a.k.a. 16777216) and you will get 0x24 (a.k.a. 36). You can see for your self with:SELECT CONVERT(varbinary(1),603979777/16777216), CONVERT(varbinary(1),0x24000001/0x1000000)Numbers are numbers, and I adwise to keep them like that.--This one's tricky. You have to use calculus and imaginary numbers for this. You know, eleventeen, thirty-twelve and all those. |
 |
|
|
avmreddy17
Posting Yak Master
180 Posts |
Posted - 2006-05-04 : 15:57:29
|
| Thanks Guys for all the help |
 |
|
|
avmreddy17
Posting Yak Master
180 Posts |
Posted - 2006-05-05 : 11:47:33
|
| RosID1 RosID2 67108865 33884956 67108865 33885211 67108865 33885212 67108865 33947907 67108865 33947921 67108865 33947922 The integer values in the RosID1 and RosID2 columns are actually the hex values.The First Byte of the RosID1 Column represents a threadID and the other three bytesrepresents a Seq Number. When I copy these values to the destination tables I have to change the first byte to a new ThreadID which I will geting as an Input parameter to the Stored Proc as integer. Also I have to get the max seqNumber from thedestination table's ROSID1 Column for the ThreadID.what is a best way to do this. Is there a set bases solution to it or we have to use a CURSOR |
 |
|
|
|
|
|
|
|