![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
The below SP (thanks to Database Journal (but simplified)) executes my DTS. However, I need to modify one of the connections (XLS file path) before execution. Thus, I would need to add another parameter @Path for example. But how do I change the connection information within the Stored Procedure. In otherwords how do I the same thing as this code: oPkg.Connections.Item(2).DataSource = strPath Here is the sp: CREATE PROCEDURE dbo.spExecuteDTSPKG @Server varchar(255), @PkgName varchar(255), -- Package Name (Defaults to most recent version) @ServerPWD varchar(255) = Null, -- Server Password if using SQL Security to load Package (UID is SUSER_NAME()) @IntSecurity bit = 1, -- 0 = SQL Server Security, 1 = Integrated Security @PkgPWD varchar(255) = '' -- Package Password AS SET NOCOUNT ON DECLARE @hr int, @ret int, @oPKG int, @Cmd varchar(1000) Select @ret = 0 -- Create a Pkg Object EXEC @hr = sp_OACreate 'DTS.Package', @oPKG OUTPUT SET @Cmd = 'LoadFromSQLServer("' + @Server +'", "", "", 256, "' + @PkgPWD + '", , , "' + @PkgName + '")' EXEC @hr = sp_OAMethod @oPKG, @Cmd, NULL -- Execute Pkg EXEC @hr = sp_OAMethod @oPKG, 'Execute' -- Unitialize the Pkg EXEC @hr = sp_OAMethod @oPKG, 'UnInitialize' -- Clean Up EXEC @hr = sp_OADestroy @oPKG RETURN @ret GO -- William R |
#3
| |||
| |||
|
|
You will have to use sp_OASetProperty on the Connection object and the property you want to set is the DataSource Property -- -- Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) www.SQLDTS.com - The site for all your DTS needs. I support PASS - the definitive, global community for SQL Server professionals - http://www.sqlpass.org "WhiskRomeo" <wrlucasD0N0TSPAM (AT) Xemaps (DOT) com> wrote in message news:8C896A13-6DE3-4F47-8BA9-3CEF0A74D6E4 (AT) microsoft (DOT) com... The below SP (thanks to Database Journal (but simplified)) executes my DTS. However, I need to modify one of the connections (XLS file path) before execution. Thus, I would need to add another parameter @Path for example. But how do I change the connection information within the Stored Procedure. In otherwords how do I the same thing as this code: oPkg.Connections.Item(2).DataSource = strPath Here is the sp: CREATE PROCEDURE dbo.spExecuteDTSPKG @Server varchar(255), @PkgName varchar(255), -- Package Name (Defaults to most recent version) @ServerPWD varchar(255) = Null, -- Server Password if using SQL Security to load Package (UID is SUSER_NAME()) @IntSecurity bit = 1, -- 0 = SQL Server Security, 1 = Integrated Security @PkgPWD varchar(255) = '' -- Package Password AS SET NOCOUNT ON DECLARE @hr int, @ret int, @oPKG int, @Cmd varchar(1000) Select @ret = 0 -- Create a Pkg Object EXEC @hr = sp_OACreate 'DTS.Package', @oPKG OUTPUT SET @Cmd = 'LoadFromSQLServer("' + @Server +'", "", "", 256, "' + @PkgPWD + '", , , "' + @PkgName + '")' EXEC @hr = sp_OAMethod @oPKG, @Cmd, NULL -- Execute Pkg EXEC @hr = sp_OAMethod @oPKG, 'Execute' -- Unitialize the Pkg EXEC @hr = sp_OAMethod @oPKG, 'UnInitialize' -- Clean Up EXEC @hr = sp_OADestroy @oPKG RETURN @ret GO -- William R |
#4
| |||
| |||
|
|
You will have to use sp_OASetProperty on the Connection object and the property you want to set is the DataSource Property -- -- Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) www.SQLDTS.com - The site for all your DTS needs. I support PASS - the definitive, global community for SQL Server professionals - http://www.sqlpass.org "WhiskRomeo" <wrlucasD0N0TSPAM (AT) Xemaps (DOT) com> wrote in message news:8C896A13-6DE3-4F47-8BA9-3CEF0A74D6E4 (AT) microsoft (DOT) com... The below SP (thanks to Database Journal (but simplified)) executes my DTS. However, I need to modify one of the connections (XLS file path) before execution. Thus, I would need to add another parameter @Path for example. But how do I change the connection information within the Stored Procedure. In otherwords how do I the same thing as this code: oPkg.Connections.Item(2).DataSource = strPath Here is the sp: CREATE PROCEDURE dbo.spExecuteDTSPKG @Server varchar(255), @PkgName varchar(255), -- Package Name (Defaults to most recent version) @ServerPWD varchar(255) = Null, -- Server Password if using SQL Security to load Package (UID is SUSER_NAME()) @IntSecurity bit = 1, -- 0 = SQL Server Security, 1 = Integrated Security @PkgPWD varchar(255) = '' -- Package Password AS SET NOCOUNT ON DECLARE @hr int, @ret int, @oPKG int, @Cmd varchar(1000) Select @ret = 0 -- Create a Pkg Object EXEC @hr = sp_OACreate 'DTS.Package', @oPKG OUTPUT SET @Cmd = 'LoadFromSQLServer("' + @Server +'", "", "", 256, "' + @PkgPWD + '", , , "' + @PkgName + '")' EXEC @hr = sp_OAMethod @oPKG, @Cmd, NULL -- Execute Pkg EXEC @hr = sp_OAMethod @oPKG, 'Execute' -- Unitialize the Pkg EXEC @hr = sp_OAMethod @oPKG, 'UnInitialize' -- Clean Up EXEC @hr = sp_OADestroy @oPKG RETURN @ret GO -- William R |
#5
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |