Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
DB King
Starting Member
21 Posts |
Posted - 2006-04-05 : 04:26:44
|
hiI am trying to use DTS to copy databases using the transfer database object and after I select the locations tab EM freezes.I have 2 instances on the same machine named: RIZVIS and RIZVIS\BI am copying a DB with one table from RIZVIS to RIZVIS\B to test the process which I will then deploy onto our production box to a backup machine (for those wondering: this procedure is not meant to cover High Availabity).I just want to copy the databases from one server to the next. Because DTS works I intend to use a bas file to run the same process for all databases. I will write a vbs file which will use the code below. The only thing, I am running the vbs using the following command:cscript cdw.vbsbut its throwing the following error:U:\cdw.vbs(2, 21) MicrosoftVBScript compilation error: Expected end of statementAny ideas ???DTS package VBS CODE:Option ExplicitPublic goPackageOld As New DTS.PackagePublic goPackage As DTS.Package2Private Sub Main()set goPackage = goPackageOldgoPackage.Name = "New Package"goPackage.Description = "DTS package description"goPackage.WriteCompletionStatusToNTEventLog = FalsegoPackage.FailOnError = FalsegoPackage.PackagePriorityClass = 2goPackage.MaxConcurrentSteps = 4goPackage.LineageOptions = 0goPackage.UseTransaction = TruegoPackage.TransactionIsolationLevel = 4096goPackage.AutoCommitTransaction = TruegoPackage.RepositoryMetadataOptions = 0goPackage.UseOLEDBServiceComponents = TruegoPackage.LogToSQLServer = FalsegoPackage.LogServerFlags = 0goPackage.FailPackageOnLogFailure = FalsegoPackage.ExplicitGlobalVariables = FalsegoPackage.PackageType = 0Dim oConnProperty As DTS.OleDBProperty'---------------------------------------------------------------------------' create package steps information'---------------------------------------------------------------------------Dim oStep as DTS.Step2Dim oPrecConstraint as DTS.PrecedenceConstraint'------------- a new step defined belowSet oStep = goPackage.Steps.NewoStep.Name = "Copy SQL Server Objects"oStep.Description = "Copy SQL Server Objects"oStep.ExecutionStatus = 1oStep.TaskName = "Copy SQL Server Objects"oStep.CommitSuccess = FalseoStep.RollbackFailure = FalseoStep.ScriptLanguage = "VBScript"oStep.AddGlobalVariables = TrueoStep.RelativePriority = 3oStep.CloseConnection = FalseoStep.ExecuteInMainThread = FalseoStep.IsPackageDSORowset = FalseoStep.JoinTransactionIfPresent = FalseoStep.DisableStep = FalseoStep.FailPackageOnError = FalsegoPackage.Steps.Add oStepSet oStep = Nothing'---------------------------------------------------------------------------' create package tasks information'---------------------------------------------------------------------------'------------- call Task_Sub1 for task Copy SQL Server Objects (Copy SQL Server Objects)Call Task_Sub1( goPackage )'---------------------------------------------------------------------------' Save or execute package'---------------------------------------------------------------------------'goPackage.SaveToSQLServer "(local)", "sa", ""goPackage.ExecutetracePackageError goPackagegoPackage.Uninitialize'to save a package instead of executing it, comment out the executing package line above and uncomment the saving package lineset goPackage = Nothingset goPackageOld = NothingEnd Sub'-----------------------------------------------------------------------------' error reporting using step.GetExecutionErrorInfo after execution'-----------------------------------------------------------------------------Public Sub tracePackageError(oPackage As DTS.Package)Dim ErrorCode As LongDim ErrorSource As StringDim ErrorDescription As StringDim ErrorHelpFile As StringDim ErrorHelpContext As LongDim ErrorIDofInterfaceWithError As StringDim i As IntegerFor i = 1 To oPackage.Steps.CountIf oPackage.Steps(i).ExecutionResult = DTSStepExecResult_Failure ThenoPackage.Steps(i).GetExecutionErrorInfo ErrorCode, ErrorSource, ErrorDescription, _ErrorHelpFile, ErrorHelpContext, ErrorIDofInterfaceWithErrorMsgBox oPackage.Steps(i).Name & " failed" & vbCrLf & ErrorSource & vbCrLf & ErrorDescriptionEnd IfNext iEnd Sub'------------- define Task_Sub1 for task Copy SQL Server Objects (Copy SQL Server Objects)Public Sub Task_Sub1(ByVal goPackage As Object)Dim oTask As DTS.TaskDim oLookup As DTS.LookupDim oCustomTask1 As DTS.TransferObjectsTask2Set oTask = goPackage.Tasks.New("DTSTransferObjectsTask")oTask.Name = "Copy SQL Server Objects"Set oCustomTask1 = oTask.CustomTaskoCustomTask1.Name = "Copy SQL Server Objects"oCustomTask1.Description = "Copy SQL Server Objects"oCustomTask1.SourceServer = "(LOCAL)"oCustomTask1.SourceUseTrustedConnection = TrueoCustomTask1.SourceDatabase = "saj01"oCustomTask1.DestinationServer = "rizvis\b"oCustomTask1.DestinationUseTrustedConnection = TrueoCustomTask1.DestinationDatabase = "saj01"oCustomTask1.ScriptFileDirectory = "C:\Program Files\Microsoft SQL Server\80\Tools"oCustomTask1.CopyAllObjects = TrueoCustomTask1.IncludeDependencies = TrueoCustomTask1.IncludeLogins = TrueoCustomTask1.IncludeUsers = TrueoCustomTask1.DropDestinationObjectsFirst = TrueoCustomTask1.CopySchema = TrueoCustomTask1.CopyData = 1oCustomTask1.ScriptOption = -2146995969oCustomTask1.ScriptOptionEx = 4722704oCustomTask1.SourceTranslateChar = TrueoCustomTask1.DestTranslateChar = TrueoCustomTask1.DestUseTransaction = FalseoCustomTask1.UseCollation = TruegoPackage.Tasks.Add oTaskSet oCustomTask1 = NothingSet oTask = NothingEnd SubHelp ???!?!?!? |
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-04-05 : 06:51:33
|
If you can use another solution you'll probably find dmo easier.seehttp://www.nigelrivett.net/DMO/SQL-DMOTransfer.html==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
DB King
Starting Member
21 Posts |
Posted - 2006-04-05 : 06:59:41
|
what is sql-dmo ? |
 |
|
|
|
|
|
|