SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 passing T-SQL parameters to a command line program
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

stevenandler
Starting Member

USA
42 Posts

Posted - 02/07/2013 :  11:58:13  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

3587 Posts

Posted - 02/07/2013 :  16:23:32  Show Profile  Reply with Quote
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

USA
42 Posts

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

James K
Flowing Fount of Yak Knowledge

3587 Posts

Posted - 02/07/2013 :  18:04:45  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000