It seems like insufficient info to tell something definitely. For example, are you deleting through Transact-SQL or through Win32API, etc.
The FILESTREAM data is not deleted immediately from file system because SQL Server transaction logging under full and bulk recovery models permit the crash recovery.
Have you deleted with CHECKPOINT
delete from tablename CHECKPOINT
or tried to execute CHECKPOINT statement or use simple recovery model?
Also, IMO,:
- changing of FILESTREAM (re)configuration require restart of SQL Server
- FILESTREAM data is restricted to LOCAL only drives
- FILESTREAM operations depend on hardware, see Paul Randal's white paper
- "deleting or renaming any FILESTREAM files directly through the file system will result in database corruption"
Check Security and Reliability sections of Paul Randal's white paper
Related discussions containing many subreferences:
Update:
Have you checked permissions of FILESTREAM (Windows) share/container vs. account under which SQL Server runs under. It should have local administrator permissions. It is recommended that no other account be granted permissions on the data container
Update2:
From Paul Randal's white paper:
- "The file system access open operations do not wait for any locks. Instead, the open operations fail immediately if they cannot access the data because of transaction isolation. The streaming API calls fail with ERROR_SHARING_VIOLATION if the open operation cannot continue because of isolation violation"
- "Antivirus software ... access to the BLOB data in the affected file will be prevented, and to SQL Server the file will appear to have been deleted."
- "Note that for a table to have one or more FILESTREAM columns, it must also have a column of the uniqueidentifier data type that has the ROWGUIDCOL attribute. This column must not allow null values and must have either a UNIQUE or PRIMARY KEY single-column constraint"
- "anything that can prevent transaction log truncation may also prevent a FILESTREAM file being physically deleted. Some examples are:"
- FILESTREAM data containers cannot be nested
Run
DBCC CHECKDB
Update3:
I cannot coach you online. This is Q&A board. I already had been banned many times for infringing the rules on StackExchange having discussions instead of posting question or answer
Run
DBCC CheckDB (QPS8, repair_rebuild)
DBCC CheckDB (QPS8) WITH No_INFOMSGS, ALL_ERRORMSGS
and put output here.
To check/set NTFS permissions: right-click on folder in Windows --> Properties --> Security
To check/set MSSQLServer: in command line type
SQLServerManager10.msc
navigate to SQL Server Services and double-click corresponding instance of SQL Server
Update 3b:
Probably, you should drop and recreate index or you have further deeper issues and you should restore database from backup or perform database repair permitting loss of data. This is quite separate topic/question.
I do not want to take any responsibility to guide you on it.
To use FILESTREAM, it has to be configured at the OS and instance level. At the OS level, FILESTREAM is enabled either during the installation of SQL Server 2008 or by running SQL Server Configuration Manager. Once FILESTREAM has been setup, you have to create a FILESTREAM filegroup. You then have to create a data container in the FILESTREAM filegroup. Once all these steps are done, you can create a table in your DB to use FILESTREAM.
(From your link) Here are the steps to configure FILESTREAM at the OS level, if not done during installation:
- On the Start menu, point to All Programs, point to Microsoft SQL
Server 2008, point to Configuration Tools, and then click SQL Server
Configuration Manager.
- In the list of services, right-click SQL Server Services, and then
click Open.
- In the SQL Server Configuration Manager snap-in, locate the instance
of SQL Server on which you want to enable FILESTREAM.
- Right-click the instance and then click Properties.
- In the SQL Server Properties dialog box, click the FILESTREAM tab.
- Select the Enable FILESTREAM for Transact-SQLAccess check box.
- If you want to read and write FILESTREAM data from Windows, click
Enable FILESTREAM for file I/O streaming access.
- Enter the name of the Windows share in the Windows Share Name box.
- If remote clients must access the FILESTREAM data that is stored on this share, select Allow remote clients to have streaming access to FILESTREAM data. Click Apply.
Next configure the SQL instance for FILESTREAM access. Run the following query on the instance (SSMS):
EXEC sp_configure filestream_access_level, 2; -- Options are 0/1/2
GO
RECONFIGURE;
GO
Now add the FILESTREAM filegroup to your DB:
ALTER DATABASE Production ADD
FILEGROUP FileStreamGroup1 CONTAINS FILESTREAM;
GO
ALTER DATABASE Production ADD FILE (
NAME = FSGroup1File,
FILENAME = 'F:\Production\FSDATA') -- Location for your data container
TO FILEGROUP FileStreamGroup1;
GO
You can now use FILESTREAM in your tables.
Best Answer
Actually you can put as many files as you want in a file group.