|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Today @ 7:54 AM
Points: 56,
Visits: 118
|
|
Here is my Query :
--select item_number from item where item_number like '%Test%'
For each item_number i would like to copy a .bmp file from the server and copy to my local drive.
-- copy \\server1\Images\<Item_number>.bmp c:\temp
Is it possible to run the above command in select statement somehow ?
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Monday, May 27, 2013 8:32 AM
Points: 75,
Visits: 412
|
|
You may use dynamic query and xp_cmdshell, smth like this:
--be sure you have permissions from DBA, and configured server: /* exec sp_configure 'show advanced options', 1 reconfigure with override exec sp_configure 'xp_cmdshell', 1 reconfigure with override */
declare @sql nvarchar(max); declare @files table (fname sysname); insert @files values ('1'),('2'),('3'); set @sql = ( select replace('exec sys.xp_cmdshell ''copy \\server1\Images\<Item_number>.bmp c:\temp'';','<Item_number>',fname) from @files for xml path('') ) print(@sql); --exec(@sql);
I am really sorry for my poor gramma. And I hope that value of my answers will outweigh the harm for your eyes. Blog: http://somewheresomehow.ru Twitter: @SomewereSomehow
|
|
|
|