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 2008 Forums
 Transact-SQL (2008)
 Passing Binary Variables To Cmdshell

Author  Topic 

mattster2020
Starting Member

6 Posts

Posted - 2012-01-06 : 08:22:27
Afternoon All,

I am using the below to pass variables to a .net application.

Declare
@Record binary(8), --the value is 0x00000000000025D6
@Filename char(150) --the value is Screenshot.jpg

select @Filename = (Select RN_Attachment_Binary_FN from Support_incident_attachment where Support_incident_attachment_id = @Record)

SET @CMD = '\\Poland\Filepath\Email_Attach_Temp\App\Save_Attachments' + CONVERT(varchar(4000),@Record) + @Filename

if I hard code values into @CMD i get the result I want. If I use the variables I get a strange output (%0) for the @record value. I think the conversion from binary to varchar is incorrect perhaps? is there anyway to output the variable @Record like this 0x00000000000025D6??

Regards,

Mattster

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-01-06 : 08:36:26
You can use master.sys.fn_varbintohexstr(@Record) but not sure if it is an undocumented (and hence scary) feature.
Go to Top of Page

mattster2020
Starting Member

6 Posts

Posted - 2012-01-06 : 10:05:28
That works. Thanks for the post :-)
Go to Top of Page
   

- Advertisement -