SQLDMO.Transfer

Med et Transfer objekt er det blandt andet muligt at

  • Finde schema eller data som skal flyttes fra én SQL Server database til en anden.
  • Finde destinationen for schema eller data som skal flyttes.
  • Overvåge afviklingen af metoderne ScriptTransfer og Transfer.
  • Stoppe en igangværende overførsel mellem to databaser.

Eksempel inspireret af VB klassen TransferEvent.cls af Gert E.R. Drapers (gertd@sqldev.net) 2003-07-29:

Dim objTransfer
Set objTransfer = CreateObject( "SQLDMO.Transfer2" )
With objTransfer
 .DestServer = "SERVER02\INSTANCE01"
 .DestDatabase = "DDBA0T_TransferTest"
 .DestUseTrustedConnection = True

 .CopySchema = True

 .CopyAllObjects = True
 .CopyAllDefaults = True
 .CopyAllFunctions = True
 .CopyAllRules = True
 .CopyAllStoredProcedures = True
 .CopyAllTables = True
 .CopyAllTriggers = True
 .CopyAllUserDefinedDatatypes = True
 .CopyAllViews = True

 .CopyData = SQLDMOCopyData_Replace
 .DropDestObjectsFirst = True

 .IncludeDependencies = True
 .IncludeDB = True
 '.IncludeLogins = True
 .IncludeUsers = True
 .ScriptType = SQLDMOScript_Default
 .Script2Type = SQLDMOScript2_Default

 .SourceTranslateChar = False
 .UseCollation = False
 .UseDestTransaction = False
End With 'objTransfer

Dim objSourceInstance
Set objSourceInstance = CreateObject( "SQLDMO.SQLServer2" )
objSourceInstance.LoginSecure = True
objSourceInstance.Connect( "SERVER01\INSTANCE01" )

Dim objDatabase
Set objDatabase = objSourceInstance.Databases( "DDBA0P_TransferTest" )
objDatabase.Transfer( objTransfer )

objSourceInstance.DisConnect

Set objDatabase = Nothing
Set objTransfer = Nothing
Set objSourceInstance = Nothing

Se også:
SQLDMO.Transfer2

Niels Grove-Rasmussen Opdateret 30-01-2008 22:58:39.
Ting Ta'r Tid! Hentet 16-11-2018 00:19:08.