Showing posts with label built. Show all posts
Showing posts with label built. Show all posts

Wednesday, March 28, 2012

Restoring using smo

I have built a VB.NET app that uses SMO to restore a database from a backup device to a database. This works great if I restore the backup into the original database. If, however, i try to restore the backup into ANOTHER database, it fails. My code looks like this (only important parts are included):

db1 = New Management.Smo.Database

db1.Name = Me.lstDatabase.SelectedItem

restore = New Management.Smo.Restore

restore.Action = Management.Smo.RestoreActionType.Database

restore.Database = db1.Name

backDeviceItem = New Management.Smo.BackupDeviceItem(Me.lstBackups.Text, Management.Smo.DeviceType.LogicalDevice)

restore.Devices.Add(backDeviceItem)

restore.ReplaceDatabase = True

restore.SqlRestore(SqlServerSelection)

In this example, the lstBackups contains the list of backup devices. lstDatabase contains the list of databases to restore into. I can successfully connect to the database, but the restore fails. Any ideas?

Thanks...

Scott

What privilege level is the user attempting to do the restore? While a db_owner user can back up a database, the restore is in essence a create database process, which requires sysadmin level privileges.|||Also the database has to be in restricted mode.

db1.DatabaseOptions.UserAccess = DatabseUserAccess.Restrictedsql

Restoring using smo

I have built a VB.NET app that uses SMO to restore a database from a backup device to a database. This works great if I restore the backup into the original database. If, however, i try to restore the backup into ANOTHER database, it fails. My code looks like this (only important parts are included):

db1 = New Management.Smo.Database

db1.Name = Me.lstDatabase.SelectedItem

restore = New Management.Smo.Restore

restore.Action = Management.Smo.RestoreActionType.Database

restore.Database = db1.Name

backDeviceItem = New Management.Smo.BackupDeviceItem(Me.lstBackups.Text, Management.Smo.DeviceType.LogicalDevice)

restore.Devices.Add(backDeviceItem)

restore.ReplaceDatabase = True

restore.SqlRestore(SqlServerSelection)

In this example, the lstBackups contains the list of backup devices. lstDatabase contains the list of databases to restore into. I can successfully connect to the database, but the restore fails. Any ideas?

Thanks...

Scott

What privilege level is the user attempting to do the restore? While a db_owner user can back up a database, the restore is in essence a create database process, which requires sysadmin level privileges.|||Also the database has to be in restricted mode.

db1.DatabaseOptions.UserAccess = DatabseUserAccess.Restricted

Wednesday, March 21, 2012

Restoring SQL 2000 Database from SQL 2005

Hi to anybody who can help on this,

I am facing problems with a Database originally built under SQL 2000 while trying to restore it from SQL 2005. Is there any incompatibility on the data bases? Otherwise, is there any change I should keep in mind and/or do before migrating to SQL 2005?

Thank you

You can restore a sql2000 backup on sql2005 without any issue.

You can NOT restore a sql2005 backup on sql2000.

System databases from sql2000 can not be restored to sql2005. Best to use an in-place upgrade performed during installation of sql2005 to handle that.

Hope that helps.