2014-09-26 10 views
0

스크립트를 사용하여 여러 테이블/인덱스를 이동했습니다. http://www.sqltechnet.com/2012/08/ssis-transfer-sql-server-object-using.html VB 스크립트 작업에 참조 및 스크립트를 입력 할 때. 이전 XFR = 새 전송 (dB)로 희미한 XFRSSIS 2014 스크립트 작업에서 smo 사용 vb "전송이 정의되지 않았습니다."

가 어떻게이 두 가지 오류를 수정합니까 : 나는이 건물에 두 가지 오류를 받고 있어요 라인에서

를 "전송이 정의되지 않은"? 당신이 어셈블리 참조가 있어야처럼 내가 "비주얼 스튜디오 2013 SQL Server 데이터 도구"를 사용하고

# 
    Region "Imports" 
    Imports Microsoft.SqlServer.Management.Smo 
    Imports Microsoft.SqlServer.Management.Common 
    Imports System 
    Imports System.Data 
    Imports System.Math 
    Imports Microsoft.SqlServer.Dts.Runtime# End Region 'ScriptMain is the entry point class of the script. Do not change the name, attributes, 
    ' 
    or parent of this class. < Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute() > _ < System.CLSCompliantAttribute(False) > _ 
    Partial Public Class ScriptMain 
    Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase 'This method is called when this script task executes in the control flow. 
     ' 
    Before returning from this method, set the value of Dts.TaskResult to indicate success or failure. 
    'To open Help, press F1. 

     Public Sub Main() 
      Dim dbSourceName As String 
      Dim dbDestName As String 
      Dim tbl_name1 As String 
      Dim SQLServername As String 
      ' 
    Set Source and destination database 
    dbSourceName = Dts.Variables("sourcedb_name").Value.ToString() 
    dbDestName = Dts.Variables("destdb_name").Value.ToString() 
    'Connect to the local, default instance of SQL Server. 
      SQLServername = Dts.Variables("SQL_Name").Value.ToString() 
      Dim srv As Server 
      srv = New Server(SQLServername) 
      ' 
    Reference the source database 
    Dim db As Database 
    db = srv.Databases(dbSourceName) 
    'Reference the destination database. 
      Dim dbCopy As Database 
      dbCopy = New Database(srv, dbDestName) 
      ' 
    Table name 
    tbl_name1 = Dts.Variables("Tbls_name").Value.ToString() 
    'Define a Transfer object and set the required options. 
      MsgBox(tbl_name1) 
      Dim xfr As Transfer 
      xfr = New Transfer(db) 
      xfr.CopyAllDatabaseTriggers = False 
      xfr.CopyAllDefaults = False 
      xfr.CopyAllLogins = False 
      xfr.CopyAllObjects = False 
      xfr.CopyAllPartitionFunctions = False 
      xfr.CopyAllPartitionSchemes = False 
      xfr.CopyAllRoles = False 
      xfr.CopyAllRules = False 
      xfr.CopyAllSchemas = False 
      xfr.CopyAllSqlAssemblies = False 
      xfr.CopyAllStoredProcedures = False 
      xfr.CopyAllSynonyms = False 
      xfr.CopyAllTables = False 
      xfr.CopyAllUserDefinedAggregates = False 
      xfr.CopyAllUserDefinedDataTypes = False 
      xfr.CopyAllUserDefinedFunctions = False 
      xfr.CopyAllUserDefinedTypes = False 
      xfr.CopyAllUsers = False 
      xfr.CopyAllViews = False 
      xfr.CopyAllXmlSchemaCollections = False 
      xfr.CreateTargetDatabase = False 
      xfr.DropDestinationObjectsFirst = False 
      xfr.PrefetchObjects = False 
      xfr.SourceTranslateChar = False 
      ' 
    Add Table to the List 
    xfr.ObjectList.Add(db.Tables(tbl_name1)) 
    xfr.Options.WithDependencies = True 
    xfr.Options.Indexes = True 
    xfr.Options.DriAll = True 
    xfr.CopySchema = True 
    xfr.DestinationDatabase = dbCopy.Name 
    xfr.DestinationServer = srv.Name 'Include data 
      xfr.CopyData = True 

      ' 
    Execute the transfer 
    xfr.TransferData() 
    Dts.TaskResult = ScriptResults.Success 
    End Sub# Region "ScriptResults declaration" 
    'This enum provides a convenient shorthand within the scope of this class for setting the 
     ' 
    result of the script. 
    'This code was generated automatically. 
     Enum ScriptResults 
      Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success 
      Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure 
     End Enum 

    #End Region 

    End Class 

답변