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
 General SQL Server Forums
 New to SQL Server Programming
 passing T-SQL parameters to a command line program

Author  Topic 

stevenandler
Starting Member

42 Posts

Posted - 2013-02-07 : 11:58:13
I am able to call the following command line program from T-SQL
if I hard code the arguments like this

!!C:\REPORT.EXE 1874 21665339


However, I am not able to pass in T-SQL variables.

DECLARE @PAT INT
DECLARE @ORD INT
SET @PAT = 1874
SET @ORD = 21665339
!!C:\REPORT.EXE @PAT @ORD


Can someone please tell me how to do this?

Thank you

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-02-07 : 16:23:32
Are you using xp_cmdshell to run the command line program from T-SQL with hardcoded arguments?
Go to Top of Page

stevenandler
Starting Member

42 Posts

Posted - 2013-02-07 : 17:29:03
No, but I am using the posted T-SQL commands with SQLCMD query activated.
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-02-07 : 18:04:45
I think you have to use SETVAR for this; I don't know of a way to force the substitution of T-SQL variables when invoking the system command. If you are able to use SETVAR, it would be something like this:
:setvar mydir "C:\Temp"
!!dir $(mydir)
Go to Top of Page
   

- Advertisement -