This example illustrates using SQL-DMO to perform a differential database backup.
' Create a Backup object and set action and source database properties.
Dim oBackup As New SQLDMO.Backup
oBackup.Action = SQLDMOBackup_Differential
oBackup.Database = "Northwind"
' Example illustrates backup implemented to a single operating system
' file. A file naming convention could be easily applied allowing
' rapid identification of a specific differential backup.
oBackup.Files = "c:\program files\microsoft sql server\mssql\backup\NorthDiff.bak"
' Optional. When backup is directed to one or more files, set media
' name, backup set name and description to provide in-file documentation
' of the file and backup set contained.
oBackup.MediaName = "NorthDiff.bak " & Date & " " & Time
oBackup.BackupSetName = "NorthDiff"
oBackup.BackupSetDescription = _
"Differential backup of Northwind sample."
' Call SQLBackup method to perform the backup. In a production
' environment, consider wrapping the method call with a wait pointer
' or use Backup object events to provide feedback to the user.
'
' Note: Create and connect of SQLServer object used is not
' illustrated in this example.
oBackup.SQLBackup oSQLServer