1

I have a FileTable in my SQL Server 2012 database, which contains both folders and files. I wanted to rename a folder, so I executed

update MyFileTable set name = 'NewName' where name = 'OldName';

The update was successful, and the file table reflects the new name when I select from it. However, when I go into Windows Explorer and navigate to the corresponding folder location, the new name is not reflected. I tried refreshing and waiting a bit, then refreshing, but the folder still has the old name. When I attempt to open the folder (with the old name) it gives an error that the location is not valid (or something to that effect), and, after clicking "OK", the folder disappears.

However, if I try to create a new folder in the same location with the new name, I get an error that the folder already exists. When I click "OK", the folder with the new name appears, plus a new folder with name "New folder" (due to the unsuccessful attempt to create the folder with a name of NewName. After deleting the folder New folder, I have the desired result: the file table is updated and the new name is reflected in Windows Explorer.

So, it seems the file table is working for the most part, but how can I make sure a name change (or other change) carried out in a query or stored procedure will be reflected in the file share?

I have googled around but have not found anything that discusses this issue.

EDIT:
I have noticed a similar thing when inserting new records into the file table. The new records (folders in this case) do not show up in Windows Explorer after creation, even though they do appear in the file table. Curiously, however, after trying different things, five recently created folders appeared in Windows Explorer all at once. So, maybe there's just a lag. Has anyone had a similar experience?

neizan
  • 2,291
  • 2
  • 37
  • 52
  • @M.Ali I don't think that's true. When I change the folder name in Windows Explorer, the new name is immediately reflected when doing a `select * from MyFileTable`. But going the other direction, the update is not reflected. – neizan Feb 16 '16 at 16:05
  • Are you saying that you think that when you change the name of a file in a Database table, that that file will automatically get renamed in your file system? – Tab Alleman Feb 16 '16 at 16:06
  • @TabAlleman Basically, yes. I am trying on a folder now, but I would expect the same for a file. Note that I am working with a FileTable, which is an object designed to perform these functions. – neizan Feb 16 '16 at 16:08

1 Answers1

1

I was recently trying to figure this out myself. After renaming a FileTable, one can use SSMS to open Properties for a FileTable. There is a FileTable page where one can manually update the FileTable directory name.

The T-SQL command is as follows:

ALTER TABLE filetable_name
SET ( FILETABLE_DIRECTORY = N'directory_name' );
GO

See Create, Alter, and Drop FileTables.

CNHume
  • 75
  • 10