Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Stored Procedure

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-07-15 : 08:25:51
Steve writes "How can I supply two parameters (uncpath and dts_package_name) to a stored procedure and use those parameters to run a shell command. I can't get this to compile:

USE fml_train
GO

IF EXISTS(SELECT * FROM sysobjects WHERE name = 'run_dts_package')
DROP PROC run_dts_package
GO

CREATE PROC run_dts_package
@MyuncFilename nvarchar(255),
@MyPackagename nvarchar(255)
AS
xp_cmdshell 'DTSRUN /F "' + @MyuncFilename + '" /N "' + @MyPackagename + '"'


Thanks in advance!"

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-07-15 : 09:35:30
It would be helpful to know what error you are getting.

<O>
Go to Top of Page

ToddV
Posting Yak Master

218 Posts

Posted - 2002-07-15 : 09:56:19
I think a couple of things will straigten this out. First, By default xp_cmdshell exists only in the master database. I think you will need to qualify this.

Second, I think you need to build the string submitted to xp_cmdshell before calling the procedure, try this:

USE fml_train
GO

IF EXISTS(SELECT * FROM sysobjects WHERE name = 'run_dts_package')
DROP PROC run_dts_package
GO

CREATE PROC run_dts_package
@MyuncFilename nvarchar(255),
@MyPackagename nvarchar(255)
AS
DECALRE @DtsRun Varchar(1000)

SET @DtsRun ='DTSRUN /F "' + @MyuncFilename + '" /N "' + @MyPackagename + '"'

EXEC master..xp_cmdshell @DtsRun

Go to Top of Page
   

- Advertisement -