Creating a Script from a Stored Procedure

  • Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/rrandall/creatingascriptfromastoredprocedure.asp

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • This is probably just a button for me, but I'd like Ryan to stay away from single letter variables. 'i' and 'q' don't tell me that much. Even if he uses iSuccess, it would be of help.

    Handy content, though.

  • Very good content. Help me a lot especially in debugging and printing reports directly from store procedures.

    One question. Is the method sp_OAXXXXX create security issues, such as the person need certain special rights, such as belongs to sysAdmin?



    Regards,
    kokyan

  • Thanks for the detailied method.  I am constantly creating scripts from existing stored procs, but have always opened the proc in Query Analyzer and simply cut and pasted into a text document, or saved the query as a new file.

    I'm curious as to when the need for this would arise.

    Thanks

  • I came across this article while looking for a size limit on the sp_OAMethod output vaiable.  It turns out that the 255 character limit that Ryan had in this article has been increased to at least 4000 bytes.  See link http://support.microsoft.com/kb/325492.

    The answer to the prior to posts (which I realize are old, but again in case some else comes to this article) are:

    1) The sp_OA% procedures are in the master database and are not granted execute to anyone other that master dbo (basically sysadmin).  You would either need to grant execute to these procedures to a user or role and add the user to master (or you could use public), or create the calling procedure (Ryan's proc) in master and just grant access to this calling procedure and the permissions should then inherit correctly since it is all within a single DB.

    2) The reason you would do something like this in a procedure rather than copy/paste from a query window is if you were executing this as a batch job and not interactively.

     

  • What would be the right Script ID to be used in order to create a script that alters the existing SP Code?

    Thanks

Viewing 6 posts - 1 through 5 (of 5 total)

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