Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1111897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:37:17+00:00 2026-05-17T02:37:17+00:00

We had a Stored Procedure written and it had a GRANT written at the

  • 0

We had a Stored Procedure written and it had a GRANT written at the last line of the SP.. Our DBA recommended that there should be a GO before the GRANT statement, else it will be executed every time.

What does this mean? I am not sure how GO will prevent GRANT executing “every time”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T02:37:17+00:00Added an answer on May 17, 2026 at 2:37 am

    A stored procedure definition doesn’t have to end with and END. If you define your procedure
    like this:

    CREATE PROCEDURE MySP AS
    SELECT field1, field2 FROM table;
    
    GO
    
    GRANT EXECUTE ON MySP TO user1;
    

    …then SQL Server will create a procedure that returns a result set, and grant execute permissions on that stored procedure to user1.

    If you do something like this, though:

    CREATE PROCEDURE MySP AS
    SELECT field1, field2 FROM table;
    
    GRANT EXECUTE ON MySP TO user1;
    

    …then SQL Server will create a procedure that both returns a result set, and grants execute permission every time that stored procedure is executed. In other words, the GRANT is included in the definition of the stored procedure. Probably not what you wanted.

    A GO statement is used to mark the end of a batch in SQL Server. It unambiguously tells SQL Server “I’m done with whatever I was executing in the previous set of statements”. It’s very good practice to add this to the end of every definition in your create scripts; this exact situation has bitten me more than once in the past.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am converting a stored procedure which I had previously written as a string
I encountered a stored procedure that had the following error handling block immediately after
We have a stored procedure that has a select statement in it: select convert(int,
I have a stored procedure in MySQL that should update a column in a
I had wrote this below stored procedure and getting incorrect statement. ALTER PROCEDURE dbo.[Counter]
I have a stored procedure that I'm positive of has no errors but I
I have a stored procedure which uses a FOR XML statement at the end
I had to change the SQL stored procedure to ORacle stored procddure.I am able
I am trying to write part of a stored procedure where there are 4
I've been working on improving the performance of a stored procedure and there is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.