-
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?
-
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.
-
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) ?
-
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
-
Forum Rules
|
|