backup/restore from Program

G

G. Dean Blake

How can I backup and restore a SQLServer DB from a .net VB program?
Thanks,
G
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top