如何在客户端调用SQLSERVER的DTS包?

2008-04-02 10:45:08来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

经常有网友问起如何在客户端调用SQLSERVER服务器端的一些脚本和对象,并且能够输入参数,我就举例说明一下如何在客户端调用SQLSERVER的DTS包,并且能够输入参数,并且能够记录日志:

测试环境:

服务器:PIII866 512MB RAID5

WINDOWS 2000 SERVER SP4 ;SQLSERVER2000+SP3

客户端:WINDOWS 2000 PRO SP4 SQLSERVER2000 CLIENT SP3

1.先在SERVER端建立一个DTS包:

这能够根据向导一步一步的完成,我就不多说了。比如我门建立了一个导入EXCEL文档到 SQLSERVER的DTS包:DTS_ExcelToSqlserver

2.在客户端建立一个批处理文档
CRUNDTS.BAT

3.用文本编辑器编辑:

@@echo off

if [%1] == [] goto Usage
if [%2] == [] goto Usage
if [%3] == [] goto Usage
if [%4] == [] goto Usage
cls

SET LOGFILE=c:\DTSRUN.LOG

echo %TIME% Manual DTS package start run......... >> %LOGFILE%
echo ------------------------------------------ >> %LOGFILE%






@dtsrun /S %1 /U %2 /P %3 /N %4 >> %LOGFILE%
if errorlevel 1 goto Error

echo %TIME% Manual DTS package end......... >> %LOGFILE%
echo ------------------------------------------ >> %LOGFILE%
PAUSE
goto FINISH

:Error
echo ------------------------------------------- >> %LOGFILE%
echo DTSRUN ERROR PLS CHECK LOG .........
echo %TIME% GlobalStore Backup abnormal end. >> %LOGFILE%
pause
goto FINISH

:Usage
echo.
echo Usage:crundts %1 servername %2 use_name %3 password %4 dts_name
:FINISH

4.保存该文档:

然后您能够在任何程式中调用,也能够手工执行,输入参数

5.测试运行:

在DOS提示符下运行:CRUNDTS SERVERNAME sa password DTS_ExcelToSqlserver


6.日志信息:

10:24:29.38 Manual DTS package start run.........
------------------------------------------
DTSRun: Loading...


Error: -2147217900 (80040E14); Provider Error: 14262 (37B6)
Error string:
Error source:
Help file:
Help context: 0

10:24:29.66 Manual DTS package end.........
------------------------------------------
10:27:29.41 Manual DTS package start run.........
------------------------------------------
DTSRun: Loading...
DTSRun: Executing...
DTSRun OnStart: DTSStep_DTSDataPumpTask_1
DTSRun OnProgress: DTSStep_DTSDataPumpTask_1; 23 Rows have been transformed or copied.; PercentComplete = 0; ProgressCount = 23
DTSRun OnFinish: DTSStep_DTSDataPumpTask_1
DTSRun: Package execution complete.
10:27:30.02 Manual DTS package end.........
------------------------------------------

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇: sql server锁机制

下一篇: SQL Server 2000安装和基本框架