May 28, 2008 at 1:15 pm
Hi
I have written a udf to convert from binary to varchar..I get the following error when I run it...any help.Thanks
When created error:Cannot add rows to sysdepends for the current object because it depends on the missing object 'master..xp_varbintohexstr'. The object will still be created.
When I try to run it: Could not find stored procedure 'master..xp_varbintohexstr'.
ALTER FUNCTION [dbo].[GetImageURL]
(@ID varbinary(50))
RETURNS varchar(50)
AS
BEGIN
DECLARE @string varchar(50)
DECLARE @binary binary(6)
SELECT @binary = @ID
EXEC master..xp_varbintohexstr @binary, @string OUTPUT
Return 'P'+ @string + '.JPG'
END
May 28, 2008 at 2:09 pm
The procedure master..xp_varbintohexstr is not a system extended stored procedure in SQL 2005. Is this something you added?
May 28, 2008 at 3:00 pm
You're going to want to tap into CLR for this. That custom extended procedure doesn't exist in a SQL Server 2005 install.
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
May 29, 2008 at 10:19 am
No UDF required... certainly, no CLR required... 😉
DECLARE @Varbinary VARBINARY(8000)
SET @Varbinary = 0x5468697320697320612074657374
SELECT @Varbinary
SELECT CAST(@VarBinary AS VARCHAR(8000))
--Jeff Moden
Change is inevitable... Change for the better is not.
May 29, 2008 at 10:40 am
Jeff Moden (5/29/2008)
No UDF required... certainly, no CLR required... 😉
DECLARE @Varbinary VARBINARY(8000)
SET @Varbinary = 0x5468697320697320612074657374
SELECT @Varbinary
SELECT CAST(@VarBinary AS VARCHAR(8000))
Nice trick Jeff...but that's not a hex string being returned...... He's looking for a "binToHex" conversion routine.
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
May 29, 2008 at 9:46 pm
OP is passing in Varbinary... I guess I don't understand... what does the input actually look like and what should the output be?
Are you suggesting that the input is in hex without the "0x" associated with varbinary?
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply