Results 1 to 3 of 3
  1. #1
    Join Date
    May 2007
    Posts
    2

    Unanswered: Problem in attaching database

    Hi all,
    I am facing a problem during attaching a database (.mdf and .ldf files are copied fro another server). the message I am getting as follows:

    messages was from 'Microsoft SQL Server Management Studio Express':

    ===================================

    Attach database failed for Server 'CTPL-1'. (Microsoft.SqlServer.Express.Smo)

    ------------------------------
    For help, click: http://go.microsoft.com/fwlink?ProdN...r&LinkId=20476

    ------------------------------
    Program Location:

    at Microsoft.SqlServer.Management.Smo.Server.AttachDa tabase(String name, StringCollection files, String owner)
    at Microsoft.SqlServer.Management.SqlManagerUI.Attach DatabaseData.PrimaryFile.Attach()
    at Microsoft.SqlServer.Management.SqlManagerUI.Attach Database.SendDataToServer()

    ===================================

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

    ------------------------------
    Program Location:

    at Microsoft.SqlServer.Management.Common.ServerConnec tion.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)
    at Microsoft.SqlServer.Management.Common.ServerConnec tion.ExecuteNonQuery(StringCollection sqlCommands, ExecutionTypes executionType)
    at Microsoft.SqlServer.Management.Smo.ExecutionManage r.ExecuteNonQuery(StringCollection queries)
    at Microsoft.SqlServer.Management.Smo.Server.AttachDa tabaseWorker(String name, StringCollection files, String owner, AttachOptions attachOptions)
    at Microsoft.SqlServer.Management.Smo.Server.AttachDa tabase(String name, StringCollection files, String owner)

    ===================================

    Could not find row in sysindexes for database ID 8, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes.
    Could not open new database 'mci'. CREATE DATABASE is aborted. (.Net SqlClient Data Provider)

    ------------------------------
    For help, click: http://go.microsoft.com/fwlink?ProdN...2&LinkId=20476

    ------------------------------
    Server Name: (local)
    Error Number: 602
    Severity: 21
    State: 50
    Line Number: 1


    ------------------------------
    Program Location:

    at System.Data.SqlClient.SqlConnection.OnError(SqlExc eption exception, Boolean breakConnection)
    at System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException exception, Boolean breakConnection)
    at System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject stateObj)
    at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
    at System.Data.SqlClient.SqlCommand.RunExecuteNonQuer yTds(String methodName, Boolean async)
    at System.Data.SqlClient.SqlCommand.InternalExecuteNo nQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
    at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
    at Microsoft.SqlServer.Management.Common.ServerConnec tion.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)

    ===============================================



    ********************************

    the followings are the command and mesage from Query Analyzer:

    *****************************************

    command:

    -- =============================================
    -- Attach database via sp_attach_db
    -- =============================================
    EXECUTE sp_attach_db @dbname = N'mci',
    @filename1 = N'd:\ifgl\database\mci.mdf',
    @filename2 = N'd:\ifgl\database\mci_log.ldf'
    GO

    *****************************************

    message:

    Server: Msg 602, Level 21, State 50, Line 1
    Could not find row in sysindexes for database ID 8, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes.

    Connection Broken

    *******************************************





    I am new to MS SQL Server and unable to solve the problem. Can anyone help me in this metter.

    Thanks in advance.

  2. #2
    Join Date
    May 2007
    Posts
    2

    Exclamation

    Can anybody give some quick solution to the above problem???

  3. #3
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    I am guessing that you just copied the mdf/ldf without actually detaching first. In that case the mdf and ldf will be invalid.

    I would suggest restoring from a backup rather than doing the detach/attach thing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •