Attaching a database in SQL 2012

  • Greetings,

    I have a database in SQL 2000 that I need to migrate to SQL 2012.

    I detached from the SQL 2000 server using sp_detach_db.

    I copied the MDF and the LDF files to a SQL 2005 machine and used

    sp_attached_db MyDatabase,

    Filename1='E:\path to the file.mdf',

    Filename2='E:\path to the file.ldf'

    This worked fine.

    I detached the database from the SQL 2005 server and attached it to a SQL 2008 server without any problems.

    I detached the databse from SQL 2008 and copied the files to a SQL 2012 server and tried to attach the database.

    Use Master

    GO

    Create Database MyDatabase

    ON

    (Filename='E:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER2012\MSSQL\Data\MyDatabase.mdf'),

    (Filename='E:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER2012\MSSQL\Data\MyDatabase.ldf')

    For Attach;

    I received this error

    Msg 5120 Level 16, State 5, Line 1

    Unable to open the physical file "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\FTData\ftrow_CompanyKeyword.ndf". Operating System error 2: "2(the system cannot file the file specified.)".

    CompanyKeyword is a full text catalog and there are 7 catalogs in this database.

    So my question is how do I attach this database and include the catalogs or exclude the catalogs.

    I will need to rebuild the catalogs one the database is attached anyway.

    Thanks for the help.

    Gary

  • To close the loop on this, so to say.

    This error:

    Msg 5120 Level 16, State 5, Line 1

    Unable to open the physical file "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\FTData\ftrow_CompanyKeyword.ndf". Operating System error 2: "2(the system cannot file the file specified.)".

    is a result of full text catalogs not being copied over to the new server, hence not being available.

    I have always used sp_attach_db to attach a database and never had a problem with full text catalogs. I just simply rebuilt them once the database was attached.

    With SQL 2012 apparently that is not the way it works.

    The error message complains that this file does not exist at the location specified in the error.

    "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\FTData\ftrow_CompanyKeyword.ndf".

    When I looked in C:\Program Files\Microsoft SQL Server, I did not see a folder named MSSQL.1

    So I searched for it and nothing was found.

    So I created the entire directory structure \MSSQL.1\MSSQL\FTData

    I went back to the SQL 2008 machine and rebuilt all the catalogs. I detached the database once again and I copied from the FTData directory all the catalog files from the SQL 2008 machine to the SQL 2012 machine and placed them in the directory I created earlier.

    I ran this again

    Use Master

    GO

    CREATE DATABASE MyDatabase

    ON

    (Filename ='E:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER2012\MSSQL\Data\MyDatabase_Data.MDF'),

    (Filename ='E:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER2012\MSSQL\Data\MyDatabase_Log.LDF')

    For Attach;

    go

    and the database was upgraded successfully.

    This leaves me with questions.

    1.) Why wasn't the directory structure created in the first place?

    2.) Did I miss something during installation?

    3.) Why was it looking on C drive instead of the E drive where the installation is?

    My suspicion is, had the directory structure been created in the first place, the catalogs would have been rebuilt as part of the upgrade process.

    Hope this helps someone else.

    Regards

    Gary

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply