If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > Execute Stored Procedure Via Batch File

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-20-12, 09:10
acidburn85 acidburn85 is offline
Registered User
 
Join Date: Sep 2011
Posts: 20
Execute Stored Procedure Via Batch File

I have a stored procedure that generates some data and dumps it into a table. I need to export data using bcp based on the data that this procedure creates. So I know how to use bcp but don't know how to execute the procedure and pass it the two variables that it needs. I googled it and sqlcmd looks promising but can get the syntax right.

The two variables are the current year and school number ie. 1112, 0021

Any thoughts?
Reply With Quote
  #2 (permalink)  
Old 01-20-12, 10:25
MCrowley MCrowley is offline
Wage drone 24601
 
Join Date: Jan 2003
Location: Massachusetts
Posts: 4,899
What is the syntax you are using right now, and what is wrong with it (error messages)?
Reply With Quote
  #3 (permalink)  
Old 01-20-12, 10:32
acidburn85 acidburn85 is offline
Registered User
 
Join Date: Sep 2011
Posts: 20
Opps forgot to post that.

Code:
sqlcmd -S 172.16.1.5\GSchool -u oncourse -p oncourse  "exec uSP_Load_StuHalfYear '1112','0021'"
Reply With Quote
  #4 (permalink)  
Old 01-20-12, 11:22
MCrowley MCrowley is offline
Wage drone 24601
 
Join Date: Jan 2003
Location: Massachusetts
Posts: 4,899
Try this:
Code:
sqlcmd -S 172.16.1.5\GSchool -u oncourse -p oncourse /Q"exec uSP_Load_StuHalfYear '1112','0021'"
Looks like you were only missing the /Q.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On