Link to home
Start Free TrialLog in
Avatar of puranik_p
puranik_pFlag for India

asked on

binary to varchar conversion

SELECT convert(varbinary,CONVERT(BINARY,120703))
RETURNS,
0x00000000000000000000000000000000000000000000000000000001D77F

AND I WANT LAST 5 CHARS OF THE RESULT. THAT IS..1D77F

when I do..
SELECT right(convert(varbinary,CONVERT(BINARY,120703)),5)

It returns me an empty string.
Avatar of Hilaire
Hilaire
Flag of France image

what about

SELECT convert(varbinary(5),120703)
the statement
SELECT right(dbo.fn_varbintohexstr(Convert(varbinary, 120703)),5)

returns 1d77f (on Sql server 2000)

- regards
mikkel
Avatar of puranik_p

ASKER

Hilaire,
your statement gives
0x0001D77F

mikkelp,
your statement gives
Invalid object name 'dbo.fn_varbintohexstr'.

Its seems to be a user defined function which is not there in my database.
and yes. I'm using SQL Server 2000
ASKER CERTIFIED SOLUTION
Avatar of mikkelp
mikkelp
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
it worked !!

thanks a lot mikkelp.

There seems to be a lot with these functions in master database that I don't know.

Thanks again.