备份
-- Create the backup device for the full MyNwind backup.
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
-- Create the backup device for the full MyNwind backup.
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
CDatabase db;
CString s1;
s1.Format("ODBC;UID=sa;PWD=%s","wei147");
db.Open("odbcname",false,false,s1);
s1.Format("backup database report to disk='e:\\report.bak\\backs.dat'"); //备份到E:\report.bak\backs.dat
db.ExecuteSQL(s1);
恢复:
恢复时用户不能打开要恢复的数据库
CDatabase db1;
s1.Format("ODBC;UID=sa;PWD=%s","wei147");
db1.Open("odbcname",false,false,s1);
s1.Format("restore database report from disk='c:\\report.bak\\backs.dat'");
db1.ExecuteSQL(s1);
db1.Close();
VC++ODBC做的