dbTalk Databases Forums  

xp_cmdshell with parameter

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss xp_cmdshell with parameter in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Paul
 
Posts: n/a

Default xp_cmdshell with parameter - 02-02-2006 , 04:08 AM






Hi,
In a DTS package, I have a SQL Task - see below...
EXEC xp_cmdshell ?

I'm trying to pass a parameter from a global variable into my SQL statement,
but it won't let me add a parameter and returns syntax error.

I have also tried 'EXEC xp_cmdshell ?,?' as there are two unnamed parameters
for xp_cmdshell, but it does not like this either.

Any Ideas?
Ta
Paul

Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: xp_cmdshell with parameter - 02-02-2006 , 04:14 AM






Hello Paul,

So you want to call xp_cmdshell inside DTS and pass in params. What are
you doing with xp_cmdshell? would you be better off using the ExecuteProcess
task?

http://www.sqldts.com/default.aspx?251

If you do want to use xp_cmdshell but pass in params then you can do it using
a variation of the following

http://www.sqldts.com/default.aspx?205


Allan





Quote:
Hi,
In a DTS package, I have a SQL Task - see below...
EXEC xp_cmdshell ?
I'm trying to pass a parameter from a global variable into my SQL
statement, but it won't let me add a parameter and returns syntax
error.

I have also tried 'EXEC xp_cmdshell ?,?' as there are two unnamed
parameters for xp_cmdshell, but it does not like this either.

Any Ideas?
Ta
Paul



Reply With Quote
  #3  
Old   
Paul
 
Posts: n/a

Default Re: xp_cmdshell with parameter - 02-02-2006 , 04:29 AM



Hi Allen,
I have created a package that uses winzip to archive off batches of files.
It currently uses a WScript.Shell in VBScript, but there is no way of
telling when the command has completed before moving onto the next file, so
to avoid multiple WScript.Shell's trying to zip files to the same .zip at the
same time and causing access errors etc I put a 'for each/next' loop to slow
the process between file adds.

This works ok'ish, but if the server loading is high, the zip process takes
longer and the the loop then isn't long enough, but at the same time I don't
want a long loop that just drags the whole process out because most of the
time the loading is light and everything runs fine. Also creating
WScript.Shell objects is slow anyway and throws visible command shell windows
up on the server which just looks messy.

(You asked!!)

So...
Essentially a VBScript creates a Command Line string, to send to Winzip that
archives off files from all over the place and the string is never that same
thing twice - hence xp_cmdshell.

Ta
Paul
"Allan Mitchell" wrote:

Quote:
Hello Paul,

So you want to call xp_cmdshell inside DTS and pass in params. What are
you doing with xp_cmdshell? would you be better off using the ExecuteProcess
task?

http://www.sqldts.com/default.aspx?251

If you do want to use xp_cmdshell but pass in params then you can do it using
a variation of the following

http://www.sqldts.com/default.aspx?205


Allan





Hi,
In a DTS package, I have a SQL Task - see below...
EXEC xp_cmdshell ?
I'm trying to pass a parameter from a global variable into my SQL
statement, but it won't let me add a parameter and returns syntax
error.

I have also tried 'EXEC xp_cmdshell ?,?' as there are two unnamed
parameters for xp_cmdshell, but it does not like this either.

Any Ideas?
Ta
Paul




Reply With Quote
  #4  
Old   
Paul
 
Posts: n/a

Default RE: xp_cmdshell with parameter - 02-02-2006 , 05:01 AM



Fixed!
Used and Execute Process Task (Thanks Allen) and used a dynamic properties
task to assign my global variable to the ProcessCommandLine
Ta
Paul

"Paul" wrote:

Quote:
Hi,
In a DTS package, I have a SQL Task - see below...
EXEC xp_cmdshell ?

I'm trying to pass a parameter from a global variable into my SQL statement,
but it won't let me add a parameter and returns syntax error.

I have also tried 'EXEC xp_cmdshell ?,?' as there are two unnamed parameters
for xp_cmdshell, but it does not like this either.

Any Ideas?
Ta
Paul

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.