G G. Dean Blake Jul 15, 2004 #1 How can I backup and restore a SQLServer DB from a .net VB program? Thanks, G
G Guest Jul 15, 2004 #2 You can do pretty much anything with T-SQL script. See SQL books online for more info. I copied this examples right out from BO: USE master EXEC sp_addumpdevice 'disk', 'MyNwind_2', 'c:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\MyNwind_2.dat' --Create the log backup device. USE master EXEC sp_addumpdevice 'disk', 'MyNwindLog1', 'c:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\MyNwindLog1.dat' -- Back up the full MyNwind database. BACKUP DATABASE MyNwind TO MyNwind_2 -- Update activity has occurred since the full database backup. -- Back up the log of the MyNwind database. BACKUP LOG MyNwind TO MyNwindLog1 RESTORE DATABASE MyNwind FILE = 'MyNwind_data_1', FILE = 'MyNwind_data_2', FILEGROUP = 'new_customers' FROM MyNwind_1 WITH NORECOVERY -- Restore the log backup. RESTORE LOG MyNwind FROM MyNwindLog1
You can do pretty much anything with T-SQL script. See SQL books online for more info. I copied this examples right out from BO: USE master EXEC sp_addumpdevice 'disk', 'MyNwind_2', 'c:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\MyNwind_2.dat' --Create the log backup device. USE master EXEC sp_addumpdevice 'disk', 'MyNwindLog1', 'c:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\MyNwindLog1.dat' -- Back up the full MyNwind database. BACKUP DATABASE MyNwind TO MyNwind_2 -- Update activity has occurred since the full database backup. -- Back up the log of the MyNwind database. BACKUP LOG MyNwind TO MyNwindLog1 RESTORE DATABASE MyNwind FILE = 'MyNwind_data_1', FILE = 'MyNwind_data_2', FILEGROUP = 'new_customers' FROM MyNwind_1 WITH NORECOVERY -- Restore the log backup. RESTORE LOG MyNwind FROM MyNwindLog1