'
' Open a connection
'
Dim strConnection As String
strConnection = "Driver={SQL Server};" & _
"Server=YourServer;" & _
"Database=Master;Trusted_Connection=YES"
Set DbConnection = New ADODB.Connection
With DbConnection
.Mode = adModeReadWrite
.Properties("Prompt") = adUseClient
Call .Open(strConnection)
End With
'
' Send a RESTORE command (Sorry, don't have BACKUP syntax)
' (Temp has some filespec in it)
' (BACKUP should be simpler, don't need the MOVE
' option as below)
'
' I'd imagine the BACKUP command would be much simpler text.
'
sql = "RESTORE DATABASE Work_DB_ARCHIVE " & vbCrLf & _
"FROM DISK = '" & Temp & "' " & vbCrLf & _
"With Move 'Logical_Data' TO 'F:\Data_ARCHIVE.mdf', " & vbCrLf & _
"Move 'Logical_log' TO 'E:\Log_ARCHIVE_log.ldf' "
DbConnection.Execute (sql)