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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Casting to float

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-02-24 : 08:13:31
Recall writes "I have a large binary field, yet know there is a float (8 bytes) somewhere in it. As I know its offset, I can get it to a variable, and it seems ok (e.g. 0x0000000000003240 - for 18) but i could not manage to return result as float. It is strange that it can be casted to money, again 8 bytes w/o any problems.

Is there a "known" way to do it? (SQL 2K)



CREATE FUNCTION dbo.getValue(@dno as tinyint)
RETURNS float
AS
BEGIN
Declare @S integer,
@deger binary(8),
@Temp decimal
if @dno > 0 Set @dno = @dno -1
Set @S=1578 + (@dno * 32) -- I know the exact "location"
SELECT @deger = SUBSTRING(ParamBuf,@S,8)
from dbo.PARAMBLOCK
WHERE ParIdx=200
--RETURN (CONVERT(float, @deger,2))
--RETURN (CAST(@deger AS float))
--SET @Temp = CAST(@deger AS decimal(10,5))
-- SET @Temp = CAST(@deger AS float)
--RETURN (@deger)
--SET @Temp = CONVERT(decimal(10,5), CONVERT(binary(8), @deger))

RETURN -- CAST(@deger as float)
-- CAST(CAST(@deger AS varbinary(8)) AS decimal(10,5))
CONVERT(decimal(10,5), CONVERT(varbinary(8), @deger))
END"
   

- Advertisement -