September 14, 2010 at 8:45 am
I am trying to extract images from a database table that contains and ID and an image column. I am using BCP and the command successfully executes however, the data is being written (I think) to the SQL server local drive but I need to have it on my local hard drive.
SET @sql = 'BCP "SELECT pat_image FROM cids_net.dbo.Patient_image where pat_id = ''003555''" QUERYOUT C:\TEMP\003555.jpg -n -S -T' + @@SERVERNAME
EXEC master.dbo.xp_CmdShell @sql
I cannot seem to see how I can make the QUERYOUT direct the output to my local PC. Anyone have a solution for this?
September 14, 2010 at 9:48 am
the server thinks C:\ drive is it's own drive....
to write to your PC, you need to use a UNC path:
\\YOURPCNAME\c$\ImageFolder
that might not work if the account that the SQL Service is running under(NOT the login you are using!) has access to network shares or not.
Lowell
September 14, 2010 at 10:04 am
Unfortunately, our network does not support that way of addressing the local PC.
September 14, 2010 at 10:17 am
in that case, if you cannot access the server's C:\Temp folder as in your example, you'll have to use some intermediate item...a vbscript, your own program, etc to connect to SQL from your PC, download the image from the db, and write it to local disk;
here's the first gfoogle item i found:
http://www.motobit.com/tips/detpg_read-write-binary-files/
Lowell
September 21, 2010 at 7:13 am
Thanks for all the tips. I wrote a VB.NET application (very small) that does the job that I need.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply