Comments
2 comments
-
Sample using ADO:
Set conn = CreateObject("ADODB.Connection")
conn.ConnectionString = "Driver={SQL Server}; Server=.; Database = master;"
conn.Open
Set recordset = conn.Execute("EXEC master..sqlbackup '-sql ""BACKUP DATABASE pubs TO DISK = [e:\temp\pubs.sqb] WITH INIT""'")
If not recordset.eof Then
rsArray = recordset.GetRows()
For f = 0 to UBound(rsArray, 2)
output = output + rsArray(0, f) + Chr(13) + Chr(10)
Next
wscript.echo(output)
End If
Set recordset = recordset.NextRecordset
If not recordset.eof Then
output = ""
rsArray = recordset.GetRows()
For f = 0 to UBound(rsArray, 2)
output = output + rsArray(0, f) + " = " + rsArray(1, f) + Chr(13) + Chr(10)
Next
wscript.echo(output)
End If
Set recordset = Nothing
Set conn = Nothing -
Hi Peter,
I'll give this a go. Somebody told me that when they ran it, NextRecordset didn't return anything...
Add comment
Please sign in to leave a comment.
Since version v4's extended stored procedure returns two result sets, a lot of people who were using VBScripts to back up databases were having trouble getting access to the second result set, since the previous version of SQL Backup only retruned a single result set.
I haven't found a way to do this using ADO in scripting, but I've found that I can use SQLDMO.dll to do it. SQLDMO is part of SQL 2000 client-side tools. Note that it's an optional component of SQL 2005, so SQL 2005 servers may not have sqldmo.dll installed.
Here is the script: