• Hi,

    Great article & good tips along the way in the reponses.  Keeping your stored procedures in a source controlled environment is as the article states rather tricky.  Using something like this is a great way to achieve it.  Also posted in the responses was asked why not keep the drop script included in the script.

    In the code posted you'll see the commented out part being   ''262150= SQLDMOScript_ObjectPermissions + SQLDMOScript_PrimaryObject + SQLDMOScript_OwnerQualify

    Then in the next line of the code, the 262150 is used in the script method.  You can find the values of these Script Method Constants in MSDN.  In the posted code 262150 = 2 + 4 + 262144.  You can add for instance SQLDMOScript_Drops (being the constant value of 1) to the equation - thus changing the value of 262150 to 262151.

    Amend the code to the value 262151 like this: oProc.Script  262151,  dbFolder & "\" & replace(oProc.Owner, "\", "-") & "_" & replace(oProc.Name, "\", "-") & ".sql"

    Run it again, and check the script generated will contain the drop script as well.