locked
USE SQLServer Query to Move Image Files From Table List From Local One Folder To A new Folder RRS feed

  • Question

  • I want to move specific image files, which or listed in a SQLServer Table from a Folder to a new folder on my computer.  

    (I have a .aspx page that will do this using SQLserver 2005, but I cannnot make it work in 2014. It does not give an error it just does not move the files.)

    Before getting into the .aspx page, I thought I would see if it can be done using a sql Query which I have 0 expersise in.

    The Table is pict, the column is p.  I want to move the listed files from E:\imagefiles\ to E:\imagefilies\currentimages

    Can someone help me with this query please?

    Monday, September 1, 2014 3:22 PM

Answers

  • Hi Don,

    According to your description, we need to verify if you use the FileTable feature to store image files within a special table in SQL Server 2014 Express. A FileTable represents a hierarchy of directories and files. It stores data related to all the nodes in that hierarchy, for both directories and the files they contain.

    If you want to move the whole directory structure in which the files are stored, you can change the directory for a FileTable via SSMS or T-SQL .

     If you just want to move the image file from one folder to another. I recommend you create new FileTable and specify the new location, copy/pasty image files to the new FileTable. Or you can insert the images into SQL Server File table via openrowset function.

    For more information, see: http://blog.sqlauthority.com/2012/04/15/sql-server-working-with-filetables-in-sql-server-2012-part-2-methods-to-insert-data-into-table/

    Regards,
    Sofiya Li


    Sofiya Li
    TechNet Community Support

    • Marked as answer by Sofiya Li Wednesday, September 10, 2014 8:59 AM
    Wednesday, September 3, 2014 8:31 AM

All replies

  • I am assuming the column p has image file names. The following query will generate the copy commands to be run (not sure which column you are filtering on). 

    select 'copy E:\imagefiles\' + p  + ' E:\imagefilies\currentimages '
    from pict
    where 'put your where clause here' = 'put your where clause here'

    Satish Kartan http://www.sqlfood.com/


    Monday, September 1, 2014 3:54 PM
  • The Database is PLF, Table=pict, column of image names is p
    Monday, September 1, 2014 4:23 PM
  • Hi Don,

    According to your description, we need to verify if you use the FileTable feature to store image files within a special table in SQL Server 2014 Express. A FileTable represents a hierarchy of directories and files. It stores data related to all the nodes in that hierarchy, for both directories and the files they contain.

    If you want to move the whole directory structure in which the files are stored, you can change the directory for a FileTable via SSMS or T-SQL .

     If you just want to move the image file from one folder to another. I recommend you create new FileTable and specify the new location, copy/pasty image files to the new FileTable. Or you can insert the images into SQL Server File table via openrowset function.

    For more information, see: http://blog.sqlauthority.com/2012/04/15/sql-server-working-with-filetables-in-sql-server-2012-part-2-methods-to-insert-data-into-table/

    Regards,
    Sofiya Li


    Sofiya Li
    TechNet Community Support

    • Marked as answer by Sofiya Li Wednesday, September 10, 2014 8:59 AM
    Wednesday, September 3, 2014 8:31 AM