简体   繁体   中英

SQL - How to attach FileStream enabled db without log file

I'm trying to attach a FileStream enabled database without a log file. My SQL looks something like this:

USE master
CREATE DATABASE MyDB 
ON PRIMARY(NAME = N'MyDB', FILENAME = 'C:\myDB.MDF' ), 
FILEGROUP myFileGroup CONTAINS FILESTREAM ( NAME = myData, FILENAME = 'C:\myFileGroup')      
For Attach

Here is the error I'm receiving:

Msg 5173, Level 16, State 3, Line 2
One or more files do not match the primary file of the database.
If you are attempting to attach a database, retry the operation with the correct files.
If this is an existing database, the file may be corrupted and should be restored from a backup.

Does anyone know if it's possible to attach a FileStream enabled database without the original log file?

I'm trying to attach a FileStream enabled database without a log file. My SQL looks something like this:

USE master
CREATE DATABASE MyDB 
ON PRIMARY(NAME = N'MyDB', FILENAME = 'C:\myDB.MDF' ), 
FILEGROUP myFileGroup CONTAINS FILESTREAM ( NAME = myData, FILENAME = 'C:\myFileGroup')      
For Attach

Here is the error I'm receiving:

Msg 5173, Level 16, State 3, Line 2
One or more files do not match the primary file of the database.
If you are attempting to attach a database, retry the operation with the correct files.
If this is an existing database, the file may be corrupted and should be restored from a backup.

Does anyone know if it's possible to attach a FileStream enabled database without the original log file?

I'm trying to attach a FileStream enabled database without a log file. My SQL looks something like this:

USE master
CREATE DATABASE MyDB 
ON PRIMARY(NAME = N'MyDB', FILENAME = 'C:\myDB.MDF' ), 
FILEGROUP myFileGroup CONTAINS FILESTREAM ( NAME = myData, FILENAME = 'C:\myFileGroup')      
For Attach

Here is the error I'm receiving:

Msg 5173, Level 16, State 3, Line 2
One or more files do not match the primary file of the database.
If you are attempting to attach a database, retry the operation with the correct files.
If this is an existing database, the file may be corrupted and should be restored from a backup.

Does anyone know if it's possible to attach a FileStream enabled database without the original log file?

Try this blog post:

http://blog.sqlauthority.com/2010/04/26/sql-server-attach-mdf-file-without-ldf-file-in-database/

I would personally go with this one:

CREATE DATABASE TestDb ON
(FILENAME = N'C:\Database\Test\TestDb.mdf')
FOR ATTACH_REBUILD_LOG
GO

And when you have your log rebuilt, you can enable filestream; or try to reattach with the filestream location.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM