Attachdb will not work

  • I created a program that will dettach a database at night so it can be backedup to regular tape (via our system backup) and then attaches it after backup.

    The dettach works great but attaching does not work.

    Any ideas why?

    Dim oSvr As New SQLDMO.SQLServer

     

    oSQLSrv.Connect "servername", "user id", "password"

    oSQLSrv.AttachDB sDBName, FileName1 & ", " & FileName2

    oSQLSrv.DisConnect

    Set oSQLSrv = Nothing

  • 1) - there is no need to perform detach/attach to make a backup !!

      That way you'll waste backupspace and you'll have downtime.

       - Make sqlserver backups using "BACKUP DATABASE ..." (check BOL) and

         have your systembackup scipping the sqlserver db-data and db-log-files.

    2) what's the error message ?

    3) Did you collect the file-locations and names (sysfiles)  before you did the detach ? (maybe someone added a file or filegroup,...)

     

     

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

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

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