Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Links Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS SQL
Oracle
DB2
MS Access
MySQL
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» Sitemap
Free Newsletters:
DatabaseDaily  
News Via RSS Feed


follow us on Twitter
Database Journal |DBA Support |SQLCourse |SQLCourse2
 

Featured Database Articles

MS SQL

Posted Sep 24, 2000

Data Transformation Services (DTS) - Page 3

By Darren Green

Sample Scripts


All samples use the OLE Automation Return Codes and Error Information stored procedures listed in SQL Server Books Online. SQL  msoleerror.sql
Simple stored procedure to execute a package. SQL  spExecutePKG.sql
Stored procedure to execute a package, with additional parameters to set up to two global variables prior to execution. SQL  spExecutePKGGlobalVariables.sql
Supporting stored procedure used to check step ExecutionResult property. (Required by spExecutePKG and spExecutePKGGlobalVariables). SQL  spDisplayPKGErrors.sql

Script Usage

I generally create the OLE Automation Return Codes and Error Information stored procedures in master, and keep the others in my utility type database in an effort to keep the master database as clean as possible. The calling parameters are the same for spExecutePKG and spExecutePKGGlobalVariables are the same, apart from the additional global variables.

Simple package execution, using integrated security:

EXEC spExecutePKGGlobalVariables @Server='MyServer', 
  @PkgName='MyPackage', @IntSecurity=1

Package execution with a package password and SQL Server security:
N.B. The SQL login comes from the current connection via SUSER_NAME()

EXEC spExecutePKGGlobalVariables @Server='MyServer', 
  @PkgName='MyPackage', @ServerPWD='xxxx', @PkgPWD='xxxx'

Set one global variable, and execute package. Results are returned in a temporary table for further analysis:

IF OBJECT_ID('tempdb..#PkgResults') IS NOT NULL
    DROP TABLE #PkgResults

CREATE TABLE #PkgResults
(
  StepName varchar(255) NOT NULL,
  StepDescription varchar(255) NOT NULL,
  Result bit NOT NULL
)

INSERT #PkgResults 
  EXEC spExecutePKGGlobalVariables @Server='MyServer', 
    @PkgName='MyPackage', @IntSecurity=1, 
    @GlobalV_1='VariableName=VariableValue'
    
SELECT StepName, StepDescription, Result FROM #PkgResults    
StepName                       StepDescription          Result 
------------------------------ ------------------------ ------
DTSStep_DTSActiveScriptTask_1  ActX: Set Filename       0
DTSStep_DTSExecuteSQLTask_1    ExecSQL: Create Table    0
DTSStep_DTSDataPumpTask_1      Data Pump Task: Import   0

Credits

These stored procedures are variations of some written by Bill Hoghead, and distributed via Neil Pike's SQL Server FAQ.



MS SQL Archives

Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 




Latest Forum Threads
MS SQL Forum
Topic By Replies Updated
SQL 2005: SSIS: Error using SQL Server credentials poverty 3 August 17th, 07:43 AM
Need help changing table contents nkawtg 1 August 17th, 03:02 AM
SQL Server Memory confifuration bhosalenarayan 2 August 14th, 05:33 AM
SQL Server Primary Key and a Unique Key katty.jonh 2 July 25th, 10:36 AM