Oi, eu tenho uma rotina em SQL e rodo via VB, é bastante simples.
Segue :
Dim cnnConectaBanco As ADODB.Connection
Dim cmdComando As ADODB.Command
Dim sOpenSql As String
Private Sub Form_Load()
Set cnnConectaBanco = New ADODB.Connection
Set cmdComando = New ADODB.Command
With cnnConectaBanco
.Provider = "SQLOLEDB"
.ConnectionString = "User ID=sa;" & _
"password=;" & _
"Data Source=SERVIDOR;" & _
"Initial Catalog=BANCODADOS"
.Open
End With
sOpenSql = "BACKUP DATABASE [master] TO DISK = N'G:Backupmaster.bak' WITH INIT , NOUNLOAD , NAME = N'Master - Backup Completo', NOSKIP , STATS = 10, NOFORMAT " & vbCrLf & _
"BACKUP DATABASE [model] TO DISK = N'G:Backupmodel.bak' WITH INIT , NOUNLOAD , NAME = N'Model - Backup Completo', NOSKIP , STATS = 10, NOFORMAT " & vbCrLf & _
"BACKUP DATABASE [msdb] TO DISK = N'G:Backupmsdb.bak' WITH INIT , NOUNLOAD , NAME = N'MSDB - Backup Completo', NOSKIP , STATS = 10, NOFORMAT " & vbCrLf
Set cmdComando.ActiveConnection = cnnConectaBanco
cmdComando.CommandTimeout = 0
cmdComando.CommandText = sOpenSql
cmdComando.Execute sOpenSql
cnnConectaBanco.Close
Set cmdComando = Nothing
Set cnnConectaBanco = Nothing
End
rogério.