Solved

OSQL with stored procedure output parameter

Posted on 2003-11-04
7
2,748 Views
Last Modified: 2012-06-21
Hi,

I tried to use osql to execute stored procedure with some input parameters and one output parameter, how I can do this.

thanks
0
Comment
Question by:changeexpert
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 9680197
post what your doing...

but

osql -SserverName -ddatabasename -E -iinputfile.sql -ooutputfile.sql

and
inputfile.sql
would look something like
/*
 run the xxx proc
*/
Declare @Outparm Varchar(8000)
Declare @RC Int

Exec @RC = ServerName.DabataseName.Owner.StoreprocedureName  'INPUT1','INPUT2',@Output Output

Print @Outparm

/* return sp execution status to DOS */
EXIT (Select @RC)



...

if not using a trusted connection then replace the -E with -Uuserid -Ppassword

 

0
 

Author Comment

by:changeexpert
ID: 9680537
Hi

Tried to run this and "stp_s_StoredProc" will accept 2 input parameters and 1 output parameter, the I will use the output parameter value as variable for another query.  This line is included in another stored proc.  Can I do this way instead of using inputfile/outputfile?

exec master..xp_cmdshell 'osql /U "SA" /P "ABC" /S "ServerName" /Q "stp_s_StoredProc"

Thanks
0
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 9680647
yes you can specify the query to be executed via the Q (Query parameter instead)
but you not going to get the output variable that way....

what are you actually trying to do...

why do you need to run this in batch...

you maybe better off constructing a wrapper stored procedure to call the ones you want to invoke...


0
 

Author Comment

by:changeexpert
ID: 9680995
Hi,

I have stored proc that sit on SQL Server A and on SQL Server B will schedule a job to execute stored proc B on SQL B and inside this stored proc will execute stored proc A on SQL A and use the output parameter value in stored proc B.

I know I can use linked server to do execute stored proc A remotely.  However, people do not like the idea of "Linked" two servers for security reason.

Thanks
0
 
LVL 50

Accepted Solution

by:
Lowfatspread earned 30 total points
ID: 9681227
but you've got a big(ger) security hole here anyway surely by having procedure with
SA user id and passwords included within them.....

wouldn't you be better scheduling the stored procedure on Server A
and then getting it to pass its output to server B ....

perhaps even doing the data transfer via replication...


or have b regularly read (for the file A produces)  
and process it that way via some temporary tables....


what is the data?
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Table where row act as column 11 69
Open A Form without Loading All the Records of Its Recordsource 6 46
Need help with a query 3 39
Need SSIS project 2 27
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question