📄 my package.bas
字号:
Set oPrecConstraint = Nothing
'------------- a precedence constraint for steps defined below
Set oStep = goPackage.Steps("Copy Data from STUD_SUBJECT to [College].[dbo].[STUD_SUBJECT] Step")
Set oPrecConstraint = oStep.precedenceConstraints.New("Create Table [College].[dbo].[STUD_SUBJECT] Step")
oPrecConstraint.StepName = "Create Table [College].[dbo].[STUD_SUBJECT] Step"
oPrecConstraint.PrecedenceBasis = 0
oPrecConstraint.Value = 4
oStep.precedenceConstraints.Add oPrecConstraint
Set oPrecConstraint = Nothing
'------------- a precedence constraint for steps defined below
Set oStep = goPackage.Steps("Copy Data from STUDENT to [College].[dbo].[STUDENT] Step")
Set oPrecConstraint = oStep.precedenceConstraints.New("Create Table [College].[dbo].[STUDENT] Step")
oPrecConstraint.StepName = "Create Table [College].[dbo].[STUDENT] Step"
oPrecConstraint.PrecedenceBasis = 0
oPrecConstraint.Value = 4
oStep.precedenceConstraints.Add oPrecConstraint
Set oPrecConstraint = Nothing
'------------- a precedence constraint for steps defined below
Set oStep = goPackage.Steps("Copy Data from SUB_COURSE to [College].[dbo].[SUB_COURSE] Step")
Set oPrecConstraint = oStep.precedenceConstraints.New("Create Table [College].[dbo].[SUB_COURSE] Step")
oPrecConstraint.StepName = "Create Table [College].[dbo].[SUB_COURSE] Step"
oPrecConstraint.PrecedenceBasis = 0
oPrecConstraint.Value = 4
oStep.precedenceConstraints.Add oPrecConstraint
Set oPrecConstraint = Nothing
'------------- a precedence constraint for steps defined below
Set oStep = goPackage.Steps("Copy Data from SUBJECTS to [College].[dbo].[SUBJECTS] Step")
Set oPrecConstraint = oStep.precedenceConstraints.New("Create Table [College].[dbo].[SUBJECTS] Step")
oPrecConstraint.StepName = "Create Table [College].[dbo].[SUBJECTS] Step"
oPrecConstraint.PrecedenceBasis = 0
oPrecConstraint.Value = 4
oStep.precedenceConstraints.Add oPrecConstraint
Set oPrecConstraint = Nothing
'------------- a precedence constraint for steps defined below
Set oStep = goPackage.Steps("Copy Data from VISITORS to [College].[dbo].[VISITORS] Step")
Set oPrecConstraint = oStep.precedenceConstraints.New("Create Table [College].[dbo].[VISITORS] Step")
oPrecConstraint.StepName = "Create Table [College].[dbo].[VISITORS] Step"
oPrecConstraint.PrecedenceBasis = 0
oPrecConstraint.Value = 4
oStep.precedenceConstraints.Add oPrecConstraint
Set oPrecConstraint = Nothing
'------------- a precedence constraint for steps defined below
Set oStep = goPackage.Steps("Copy Data from Query1 to [College].[dbo].[Query1] Step")
Set oPrecConstraint = oStep.precedenceConstraints.New("Create Table [College].[dbo].[Query1] Step")
oPrecConstraint.StepName = "Create Table [College].[dbo].[Query1] Step"
oPrecConstraint.PrecedenceBasis = 0
oPrecConstraint.Value = 4
oStep.precedenceConstraints.Add oPrecConstraint
Set oPrecConstraint = Nothing
'------------- a precedence constraint for steps defined below
Set oStep = goPackage.Steps("Copy Data from Query2 to [College].[dbo].[Query2] Step")
Set oPrecConstraint = oStep.precedenceConstraints.New("Create Table [College].[dbo].[Query2] Step")
oPrecConstraint.StepName = "Create Table [College].[dbo].[Query2] Step"
oPrecConstraint.PrecedenceBasis = 0
oPrecConstraint.Value = 4
oStep.precedenceConstraints.Add oPrecConstraint
Set oPrecConstraint = Nothing
'------------- a precedence constraint for steps defined below
Set oStep = goPackage.Steps("Copy Data from Query3 to [College].[dbo].[Query3] Step")
Set oPrecConstraint = oStep.precedenceConstraints.New("Create Table [College].[dbo].[Query3] Step")
oPrecConstraint.StepName = "Create Table [College].[dbo].[Query3] Step"
oPrecConstraint.PrecedenceBasis = 0
oPrecConstraint.Value = 4
oStep.precedenceConstraints.Add oPrecConstraint
Set oPrecConstraint = Nothing
'------------- a precedence constraint for steps defined below
Set oStep = goPackage.Steps("Copy Data from Query4 to [College].[dbo].[Query4] Step")
Set oPrecConstraint = oStep.precedenceConstraints.New("Create Table [College].[dbo].[Query4] Step")
oPrecConstraint.StepName = "Create Table [College].[dbo].[Query4] Step"
oPrecConstraint.PrecedenceBasis = 0
oPrecConstraint.Value = 4
oStep.precedenceConstraints.Add oPrecConstraint
Set oPrecConstraint = Nothing
'------------- a precedence constraint for steps defined below
Set oStep = goPackage.Steps("Copy Data from STUD_SUBJECT Query to [College].[dbo].[STUD_SUBJECT Query] Step")
Set oPrecConstraint = oStep.precedenceConstraints.New("Create Table [College].[dbo].[STUD_SUBJECT Query] Step")
oPrecConstraint.StepName = "Create Table [College].[dbo].[STUD_SUBJECT Query] Step"
oPrecConstraint.PrecedenceBasis = 0
oPrecConstraint.Value = 4
oStep.precedenceConstraints.Add oPrecConstraint
Set oPrecConstraint = Nothing
'------------- a precedence constraint for steps defined below
Set oStep = goPackage.Steps("Copy Data from STUDENT Query to [College].[dbo].[STUDENT Query] Step")
Set oPrecConstraint = oStep.precedenceConstraints.New("Create Table [College].[dbo].[STUDENT Query] Step")
oPrecConstraint.StepName = "Create Table [College].[dbo].[STUDENT Query] Step"
oPrecConstraint.PrecedenceBasis = 0
oPrecConstraint.Value = 4
oStep.precedenceConstraints.Add oPrecConstraint
Set oPrecConstraint = Nothing
'------------- a precedence constraint for steps defined below
Set oStep = goPackage.Steps("Copy Data from STUDENT Query1 to [College].[dbo].[STUDENT Query1] Step")
Set oPrecConstraint = oStep.precedenceConstraints.New("Create Table [College].[dbo].[STUDENT Query1] Step")
oPrecConstraint.StepName = "Create Table [College].[dbo].[STUDENT Query1] Step"
oPrecConstraint.PrecedenceBasis = 0
oPrecConstraint.Value = 4
oStep.precedenceConstraints.Add oPrecConstraint
Set oPrecConstraint = Nothing
'---------------------------------------------------------------------------
' create package tasks information
'---------------------------------------------------------------------------
'------------- call Task_Sub1 for task Create Table [College].[dbo].[COURSE] Task (Create Table [College].[dbo].[COURSE] Task)
Call Task_Sub1(goPackage)
'------------- call Task_Sub2 for task Copy Data from COURSE to [College].[dbo].[COURSE] Task (Copy Data from COURSE to [College].[dbo].[COURSE] Task)
Call Task_Sub2(goPackage)
'------------- call Task_Sub3 for task Create Table [College].[dbo].[EMPLOYEE] Task (Create Table [College].[dbo].[EMPLOYEE] Task)
Call Task_Sub3(goPackage)
'------------- call Task_Sub4 for task Copy Data from EMPLOYEE to [College].[dbo].[EMPLOYEE] Task (Copy Data from EMPLOYEE to [College].[dbo].[EMPLOYEE] Task)
Call Task_Sub4(goPackage)
'------------- call Task_Sub5 for task Create Table [College].[dbo].[EXAMS] Task (Create Table [College].[dbo].[EXAMS] Task)
Call Task_Sub5(goPackage)
'------------- call Task_Sub6 for task Copy Data from EXAMS to [College].[dbo].[EXAMS] Task (Copy Data from EXAMS to [College].[dbo].[EXAMS] Task)
Call Task_Sub6(goPackage)
'------------- call Task_Sub7 for task Create Table [College].[dbo].[QUALIFICATION] Task (Create Table [College].[dbo].[QUALIFICATION] Task)
Call Task_Sub7(goPackage)
'------------- call Task_Sub8 for task Copy Data from QUALIFICATION to [College].[dbo].[QUALIFICATION] Task (Copy Data from QUALIFICATION to [College].[dbo].[QUALIFICATION] Task)
Call Task_Sub8(goPackage)
'------------- call Task_Sub9 for task Create Table [College].[dbo].[STUD_SUBJECT] Task (Create Table [College].[dbo].[STUD_SUBJECT] Task)
Call Task_Sub9(goPackage)
'------------- call Task_Sub10 for task Copy Data from STUD_SUBJECT to [College].[dbo].[STUD_SUBJECT] Task (Copy Data from STUD_SUBJECT to [College].[dbo].[STUD_SUBJECT] Task)
Call Task_Sub10(goPackage)
'------------- call Task_Sub11 for task Create Table [College].[dbo].[STUDENT] Task (Create Table [College].[dbo].[STUDENT] Task)
Call Task_Sub11(goPackage)
'------------- call Task_Sub12 for task Copy Data from STUDENT to [College].[dbo].[STUDENT] Task (Copy Data from STUDENT to [College].[dbo].[STUDENT] Task)
Call Task_Sub12(goPackage)
'------------- call Task_Sub13 for task Create Table [College].[dbo].[SUB_COURSE] Task (Create Table [College].[dbo].[SUB_COURSE] Task)
Call Task_Sub13(goPackage)
'------------- call Task_Sub14 for task Copy Data from SUB_COURSE to [College].[dbo].[SUB_COURSE] Task (Copy Data from SUB_COURSE to [College].[dbo].[SUB_COURSE] Task)
Call Task_Sub14(goPackage)
'------------- call Task_Sub15 for task Create Table [College].[dbo].[SUBJECTS] Task (Create Table [College].[dbo].[SUBJECTS] Task)
Call Task_Sub15(goPackage)
'------------- call Task_Sub16 for task Copy Data from SUBJECTS to [College].[dbo].[SUBJECTS] Task (Copy Data from SUBJECTS to [College].[dbo].[SUBJECTS] Task)
Call Task_Sub16(goPackage)
'------------- call Task_Sub17 for task Create Table [College].[dbo].[VISITORS] Task (Create Table [College].[dbo].[VISITORS] Task)
Call Task_Sub17(goPackage)
'------------- call Task_Sub18 for task Copy Data from VISITORS to [College].[dbo].[VISITORS] Task (Copy Data from VISITORS to [College].[dbo].[VISITORS] Task)
Call Task_Sub18(goPackage)
'------------- call Task_Sub19 for task Create Table [College].[dbo].[Query1] Task (Create Table [College].[dbo].[Query1] Task)
Call Task_Sub19(goPackage)
'------------- call Task_Sub20 for task Copy Data from Query1 to [College].[dbo].[Query1] Task (Copy Data from Query1 to [College].[dbo].[Query1] Task)
Call Task_Sub20(goPackage)
'------------- call Task_Sub21 for task Create Table [College].[dbo].[Query2] Task (Create Table [College].[dbo].[Query2] Task)
Call Task_Sub21(goPackage)
'------------- call Task_Sub22 for task Copy Data from Query2 to [College].[dbo].[Query2] Task (Copy Data from Query2 to [College].[dbo].[Query2] Task)
Call Task_Sub22(goPackage)
'------------- call Task_Sub23 for task Create Table [College].[dbo].[Query3] Task (Create Table [College].[dbo].[Query3] Task)
Call Task_Sub23(goPackage)
'------------- call Task_Sub24 for task Copy Data from Query3 to [College].[dbo].[Query3] Task (Copy Data from Query3 to [College].[dbo].[Query3] Task)
Call Task_Sub24(goPackage)
'------------- call Task_Sub25 for task Create Table [College].[dbo].[Query4] Task (Create Table [College].[dbo].[Query4] Task)
Call Task_Sub25(goPackage)
'------------- call Task_Sub26 for task Copy Data from Query4 to [College].[dbo].[Query4] Task (Copy Data from Query4 to [College].[dbo].[Query4] Task)
Call Task_Sub26(goPackage)
'------------- call Task_Sub27 for task Create Table [College].[dbo].[STUD_SUBJECT Query] Task (Create Table [College].[dbo].[STUD_SUBJECT Query] Task)
Call Task_Sub27(goPackage)
'------------- call Task_Sub28 for task Copy Data from STUD_SUBJECT Query to [College].[dbo].[STUD_SUBJECT Query] Task (Copy Data from STUD_SUBJECT Query to [College].[dbo].[STUD_SUBJECT Query] Task)
Call Task_Sub28(goPackage)
'------------- call Task_Sub29 for task Create Table [College].[dbo].[STUDENT Query] Task (Create Table [College].[dbo].[STUDENT Query] Task)
Call Task_Sub29(goPackage)
'------------- call Task_Sub30 for task Copy Data from STUDENT Query to [College].[dbo].[STUDENT Query] Task (Copy Data from STUDENT Query to [College].[dbo].[STUDENT Query] Task)
Call Task_Sub30(goPackage)
'------------- call Task_Sub31 for task Create Table [College].[dbo].[STUDENT Query1] Task (Create Table [College].[dbo].[STUDENT Query1] Task)
Call Task_Sub31(goPackage)
'------------- call Task_Sub32 for task Copy Data from STUDENT Query1 to [College].[dbo].[STUDENT Query1] Task (Copy Data from STUDENT Query1 to [College].[dbo].[STUDENT Query1] Task)
Call Task_Sub32(goPackage)
'---------------------------------------------------------------------------
' Save or execute package
'---------------------------------------------------------------------------
'goPackage.SaveToSQLServer "(local)", "sa", ""
goPackage.Execute
goPackage.Uninitialize
'to save a package instead of executing it, comment out the executing package line above and uncomment the saving package line
Set goPackage = Nothing
Set goPackageOld = Nothing
End Sub
'------------- define Task_Sub1 for task Create Table [College].[dbo].[COURSE] Task (Create Table [College].[dbo].[COURSE] Task)
Public Sub Task_Sub1(ByVal goPackage As Object)
Dim oTask As DTS.Task
Dim oLookup As DTS.Lookup
Dim oCustomTask1 As DTS.ExecuteSQLTask2
Set oTask = goPackage.Tasks.New("DTSExecuteSQLTask")
Set oCustomTask1 = oTask.CustomTask
oCustomTask1.Name = "Create Table [College].[dbo].[COURSE] Task"
oCustomTask1.Description = "Create Table [College].[dbo].[COURSE] Task"
oCustomTask1.SQLStatement = "CREATE TABLE [College].[dbo].[COURSE] (" & vbCrLf
oCustomTask1.SQLStatement = oCustomTask1.SQLStatement & "[COURSE_ID] int NULL, " & vbCrLf
oCustomTask1.SQLStatement = oCustomTask1.SQLStatement & "[COURSE_NAME] nvarchar (50) NULL, " & vbCrLf
oCustomTask1.SQLStatement = oCustomTask1.SQLStatement & "[DESCRIPTION] nvarchar (50) NULL, " & vbCrLf
oCustomTask1.SQLStatement = oCustomTask1.SQLStatement & "[SEMESTER] int NULL" & vbCrLf
oCustomTask1.SQLStatement = oCustomTask1.SQLStatement & ")"
oCustomTask1.ConnectionID = 2
oCustomTask1.CommandTimeout = 0
oCustomTask1.OutputAsRecordset = False
goPackage.Tasks.Add oTask
Set oCustomTask1 = Nothing
Set oTask = Nothing
End Sub
'------------- define Task_Sub2 for task Copy Data from COURSE to [College].[dbo].[COURSE] Task (Copy Data from COURSE to [College].[dbo].[COURSE] Task)
Public Sub Task_Sub2(ByVal goPackage As Object)
Dim oTask As DTS.Task
Dim oLookup As DTS.Lookup
Dim oCustomTask2 As DTS.DataPumpTask2
Set oTask = goPackage.Tasks.New("DTSDataPumpTask")
Set oCustomTask2 = oTask.CustomTask
oCustomTask2.Name = "Copy Data from COURSE to [College].[dbo].[COURSE] Task"
oCustomTask2.Description = "Copy Data from COURSE to [College].[dbo].[COURSE] Task"
oCustomTask2.SourceConnectionID = 1
oCustomTask2.SourceSQLStatement = "select `COURSE_ID`,`COURSE_NAME`,`DESCRIPTION`,`SEMESTER` from `COURSE`"
oCustomTask2.DestinationConnectionID = 2
oCustomTask2.DestinationObjectName = "[College].[dbo].[COURSE]"
oCustomTask2.ProgressRowCount = 1000
oCustomTask2.MaximumErrorCount = 0
oCustomTask2.FetchBufferSize = 1
oCustomTask2.UseFastLoad = True
oCustomTask2.InsertCommitSize = 0
oCustomTask2.ExceptionFileColumnDelimiter = "|"
oCustomTask2.ExceptionFileRowDelimiter = vbCrLf
oCustomTask2.AllowIdentityInserts = False
oCustomTask2.FirstRow = 0
oCustomTask2.LastRow = 0
oCustomTask2.FastLoadOptions = 2
oCustomTask2.ExceptionFileOptions = 1
oCustomTask2.DataPumpOptions = 0
Call oCustomTask2_Trans_Sub1(oCustomTask2)
goPackage.Tasks.Add oTask
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -