locked
stored procedure RRS feed

  • Question

  • i have create many stored procedures in a .sql file, then i have to run the script in another servers.

    but when i run the script, it prompts error message, then i have to add "GO" at the end of each stored pro.

    why?

    also, before i run many create/alter stored procedures scripts, is it need to set XXXX=ON/OFF, the script like that script before running each stored pro.??? 

    Thursday, October 17, 2013 3:56 PM

Answers

  • but when i run the script, it prompts error message, then i have to add "GO" at the end of each stored pro. why?

    Hello,

    Because a CREATE PROCEDURE must be the first statement within a SQL batch, therefore you have to separate each CREATE command with a batch separator GO.

    See CREATE PROCEDURE (Transact-SQL) => Limitations and Restrictions

    "The CREATE PROCEDURE statement cannot be combined with other Transact-SQL statements in a single batch."


    Olaf Helper

    [ Blog] [ Xing] [ MVP]


    • Edited by Olaf HelperMVP Thursday, October 17, 2013 4:06 PM
    • Proposed as answer by SQLZealotsEditor Thursday, October 17, 2013 4:15 PM
    • Marked as answer by Sofiya Li Thursday, October 24, 2013 9:00 AM
    Thursday, October 17, 2013 4:03 PM