Results 1 to 4 of 4

Thread: attaching db error after copy

  1. #1
    Join Date
    Mar 2005
    Posts
    5

    attaching db error after copy

    i tried to copy the database manually by using sqldmo
    here r my codes:


    On Error GoTo CopySQLDB_Err

    'Create Objects
    Set sql = CreateObject("SQLDMO.SQLServer")
    Set db = CreateObject("SQLDMO.Database")

    'Connect to the server
    sql.Connect strSrv, strLogin, strPwd

    'Set the database object
    Set db = sql.Databases(strDatabase, "dbo")

    'Determine the location of database files, primary and log
    strMDFfilePath = db.PrimaryFilePath
    strMDFfileName = _
    Trim(db.FileGroups.Item(1).DBFiles.Item(1).Physica lName)
    strLOGfile = Trim(db.TransactionLog.LogFiles(1).PhysicalName)

    'Clear out the database object
    Set db = Nothing

    'Detach database to allow copying
    sql.DetachDB (strDatabase)

    'Copy database files to new names
    FileCopy strMDFfileName, strMDFfilePath & strNewName & ".mdf"
    FileCopy strLOGfile, strMDFfilePath & strNewName & "_log.ldf"

    problem comes when i tried to attach the db using enterprise manager, error come out :

    "passed to log scan in database "SIPS' is invalid" come out ...what is the problem of this?

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    Try copy db files in windows explorer to see if you have some error. If not, then your code doesn't handle file copy properly.

  3. #3
    Join Date
    Mar 2005
    Posts
    5

    attaching db error after copy

    how s the proper way to copy a database to another (where we can specify the file property such as new database name ,physical filename and physical logfilename) ?

  4. #4
    Join Date
    Sep 2002
    Posts
    5,938
    Why don't use backup/restore or dts?

Posting Permissions

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