Sql-server – Indexes file damaged, was on ramdisk

indexsql serversql-server-2008sql-server-2008-r2

I have put some of my indexes into a filegroup that contains one file, that file is on the ramdisk, the performance is great, but the problem is that the file was deleted incorrectly (the file contains only index information). I tried to delete that file from database properties, but an error occured:

Alter failed for Database 'xxxxxx'. (Microsoft.SqlServer.Smo)

An exception occurred while executing a Transact-SQL statement or
batch. (Microsoft.SqlServer.ConnectionInfo)

The operating system returned error 21(failed to retrieve text for
this error. Reason: 15105) to SQL Server during a write at offset
0x0000002c668000 in file 'R:\DBIndexes.mdf'. Additional messages in
the SQL Server error log and system event log may provide more detail.
This is a severe system-level error condition that threatens database
integrity and must be corrected immediately. Complete a full database
consistency check (DBCC CHECKDB). This error can be caused by many
factors; for more information, see SQL Server Books Online. (Microsoft
SQL Server, Error: 823)

I have no problem to re-build the indxes, but I need to fix the database!!

I deleted all of the indexes that stores in that file, And tried to delete the file group, but the same error occured


*UPDATE*

When I detached the database, I couldn't re-attache it, it now saying:
Unable to open the physical file "R:\DBIndexes.mdf". Operating system error 2: "2(failed to retrieve text for this error. Reason: 15105)".

It was working fine before detaching it, but the small problem was in deleting that orphan file!!!

Best Answer

Once the database is detached you will probably not be able to attach the data files. Since the file operation that occurred is an almost guaranteed data corruption I think your best option here is to perform a restore from a native SQL server backup or export of some kind, or recover any snapshots you might have taken of the environment.