Results 1 to 2 of 2

Thread: Passing parameters with xp_cmdshell

  1. #1
    Chris Thorpe Guest

    Passing parameters with xp_cmdshell

    Is it possible to pass a parameter to an NT shell batch script when using the xp_cmdshell extended stored procedure?

  2. #2
    Kelly Rowe Guest

    Passing parameters with xp_cmdshell (reply)

    Should be, but you will have to build your xp_cmdshell string in SQL. Quotes may be a pain, though... For example,

    select @command0 = "'" + "E:foldernamemycommand.exe " + @parm1 + " " + @parm2 + "'"
    select @command = "xp_cmdshell " + @command0
    exec @command

    There may be some clever way to handle the quotation marks in one select, but it's 2:30 AM and I'm not alert enough to think it through. This should get ya started though.

    Kelly Rowe
    RHI Consulting

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •