MS2000数据转换服务部署

来源:互联网 发布:js预加载页面动画 编辑:程序博客网 时间:2024/06/05 17:53
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

1.目标

MSSQLServer做大数据量传输的时候,我们大多会用到数据传输服务。现在假设,在开发环境下,我们已经好了DTS包并且运行良好,接下来我们要做的事情是迁移和部署这个DTS数据包。所以,我们需要把设计环境下的DTS包保存成结构化的存储文件,并且这个文件导入到目标环境下的MSSQLServer中,最后添加作业,让MSSQLServerAngent在我们预期的事情执行这个DTS包完成数据传输工作。其中需要重点解决的一个问题是,在目标环境中,DTS传输的源和目的地会发生改变,需要对它进行配置。

2.解决方案

2.1.DTSRun

DTSRun是微软提供的命令用于执行DTS包(包括结构化存储的、存储在SQLServer或存储在MetaDataServices的包)。

dtsrun的用法:
dtsrun
[/?]|
[
    [
        /[~]Sserver_name[/instance_name]
        {{/[~]Uuser_name[/[~]Ppassword]}|/E}
    ]
    {    
        {/[~]Npackage_name}
        |{/[~]Gpackage_guid_string}
        |{/[~]Vpackage_version_guid_string}
    }
    [/[~]Mpackage_password]
    [/[~]Ffilename]
    [/[~]Rrepository_database_name]
    [/Aglobal_variable_name:typeid=value]
    [/Llog_file_name]
    [/WNT_event_log_completion_status]
    [/Z][/!X][/!D][/!Y][/!C]
]
具体的用法参看微软的资料。这里需要重点指出的是,通过“/Aglobal_variable_name:typeid=value”选项,我们可以给DTS包传递多个自定义的参数,在DTS包部署的目标环境下,我们用这个选项告诉DTS包服务器名称、用户名、密码等连接信息。通过“/!Y”选项可以获取加密后的DTSRun参数。



2.2.重新设计DTS包

为了处理DTSRun传入的自定义参数,DTS包需要重新设计。我们可以增加一个ActiveXScript任务,在ActiveXScript任务中通过VBScript或者Script对DTS,并且定义流程,把ActiveXScript任务设置成最开始的一个任务。由于DTSCOM对象线程模式与ActiveXScript任务宿主的不一致,需要将ActiveXScript任务工作流属性设置成在主包线程中执行,否则可能会出现调用错误。

下面的例子是ActiveXScript任务中的脚本。例子中的DTS包包含名称为"DBConnection"的数据库连接对象。



'************************************************************************'ActiveXScript'************************************************************************FunctionMain()DiMSDBDataSourceDiMSDBCatalogDiMSDBUserIDDiMSDBPasswordDimbDBUseTrustedDiMSOLAPServerDiMSOLAPCatalogDimoPackageDimoConnectionDimoTaskDimoCustomTask'获取DTSRun传入的自定义参数sDBDataSource=DTSGlobalVariables("DBDataSource").ValuesDBCatalog=DTSGlobalVariables("DBCatalog").ValuesDBUserID=DTSGlobalVariables("DBUserID").ValuesDBPassword=DTSGlobalVariables("DBPassword").ValuebDBUseTrusted=DTSGlobalVariables("DBUseTrusted").ValuesOLAPServer=DTSGlobalVariables("OLAPServer").ValuesOLAPCatalog=DTSGlobalVariables("OLAPCatalog").Value'取得当前DTS包对象的技巧SetoPackage=DTSGlobalVariables.Parent'取得包中的数据连接对象SetoConnection=oPackage.Connections("DBConnection")'配置数据源对象的数据连接信息IfbDBUseTrustedThenoConnection.UseTrustedConnection=bDBUseTrustedElseoConnection.UserID=sDBUserIDoConnection.Password=sDBPasswordEndIfoConnection.DataSource=sDBDataSourceoConnection.Catalog=sDBCatalogSetoConnection=nothing'配置跟多的信息,这里是OLAP分析服务处理任务SetoTask=oPackage.Tasks("DTSTask_DTSOlapProcess.Certificate")SetoCustomTask=oTask.CustomTaskSetoTask=nothingoCustomTask.Properties("TreeKey").Value=sOLAPServer&"/"_&sOLAPCatalog&"/CubeFolder/Certificate"SetoCustomTask=nothing'返回成功状态Main=DTSTaskExecResult_SuccessEndFunction共2页  第1页 
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>