xp_cmdshell with varbinary

  • Hi,

    has someone an idea, how to save a varbinary with xp_cmdshell?

    I try the following:

    DECLARE @cmd sysname;

    DECLARE @blob varbinary;

    select @blob=datei from person.address where addressid=1;

    SET @cmd = 'copy ' + @blob + '' C:\test.doc''

    EXEC master..xp_cmdshell @cmd;

    the variable @blob contains an doc-file.

    regards martin

  • You can use the below query to take the varbinary output to a file.

    Exec master.dbo.xp_cmdshell 'osql -E -S. -Q"select datei from person.address where addressid=1" -o"C:\test.doc" -ddatabasename'

  • hi, thank you for your reply:

    I tried the following:

    Exec master.dbo.xp_cmdshell 'osql -E -S. -Q"select datei from person.address where addressid=1" -o"C:\test.doc" -d"AdventureWorks"'

    But when i look into the doc-file: the content is the columnname "Datei" and not the content of the column

    do you have another suggestion?

    regards

    martin

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply