Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2011
    Posts
    22

    Unanswered: 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?

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    What is the syntax you are using right now, and what is wrong with it (error messages)?

  3. #3
    Join Date
    Sep 2011
    Posts
    22
    Opps forgot to post that.

    Code:
    sqlcmd -S 172.16.1.5\GSchool -u oncourse -p oncourse  "exec uSP_Load_StuHalfYear '1112','0021'"

  4. #4
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    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.

Posting Permissions

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