grant access to function

  • I know you can grant access to a stored procedure by added this to the bottom of a stored procedure.

    GRANT EXECUTE ON myStoredProcedureName TO PUBLIC

    How do you grant access to the public for a function? :ermm: I tried adding "GRANT SELECT ON [myfunction] TO PUBLIC" but I keep getting "Invalid use of a side-effecting operator 'GRANT' within a function."

  • sounds like you need a GO statement between the function and the GRANT SELECT myFunction statement.

    the function is trying to compile with the GRANT statement as part of it's body,and that's not allowed.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • It worked when I changed it to execute instead of select. Thnx 🙂

  • For FUNCTION, when it is a TVF, you have to use "GRANT SELECT". Otherwise, "GRANT EXEC".

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply