June 30, 2009 at 10:08 am
If I alter a procedure and tell SSMS to script out permissions and then have something like
ALTER PROCEDURE
...blah...
GRANT EXECUTE ...blah
And execute that then it works, but when I right click on the sproc, go to properties and look at permissions the "Permissions for user..." window is blanked out.
However, if I use "GO" before "grant execute" then when I open that window up, it shows "permissions for some user" with the proper permissions options being listed there.
So what is the GO statement doing there?
June 30, 2009 at 10:12 am
Maxer (6/30/2009)
So what is the GO statement doing there?
Signalling the end of the batch and the end of the stored procedure. If you don't put that there, the GRANT EXEC is considered part of the stored procedure's code (view the definition of the proc)
A ; is a statement terminator, not the same as a batch terminator, which is what GO is.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 30, 2009 at 10:18 am
Of course!
AH!
Thank you, that makes much more sense now.
For some reason I was thinking the END statement was sufficient to signal the SPROC was done.
June 30, 2009 at 10:29 am
Begins and ends just denote blocks of code in a stored proc.
CREATE PROCEDURE BeginEnd
AS
SELECT 'Before Begin'
BEGIN
SELECT 'Number 1'
END
BEGIN
SELECT 'Number 2'
END
BEGIN
SELECT 'Number 3'
END
SELECT 'After end'
GO
EXEC BeginEnd
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply