SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Save Your Stored Procedures


Save Your Stored Procedures

Author
Message
Rob Sanguin
Rob Sanguin
SSC-Enthusiastic
SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)SSC-Enthusiastic (136 reputation)

Group: General Forum Members
Points: 136 Visits: 78

Just a warning note about the EXCLUDE list - you should probably add start and end delimiters to your excluded DB names to prevent a custom DB called My_master being excluded too.

So the excluded list would be /master/model/...etc.../ and the comparison code would be with "/" & DBName & "/" rather than just DBName on its own.


Thysie
Thysie
SSC Rookie
SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)

Group: General Forum Members
Points: 27 Visits: 93

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.





Liam Kelly
Liam Kelly
Forum Newbie
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: General Forum Members
Points: 7 Visits: 1
As a newbie I would love to implement this and can follow the logic in the command but have no idea how to run it. Apparently you all have a knowledge of VB script but for me, with no such knowledge, it would be good to have a 1,2,3 on how to run this easily. Is there a source for downloadng the tools I need to run this?
We recently had a SP get trashed so this type of backup would be excellent to have.
richteel
richteel
SSC Rookie
SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)

Group: General Forum Members
Points: 30 Visits: 23

You do not need any tools to run this. Just copy the code that is posted in the article, open notepad and paste the code in a new text document. Save the file with a ".vbs" extension and double click on the file to run it. Depending on the Windows Version you are running, you may have a dialog box prompt you that running scripts may not be safe do you wish to run the script or block it. From the dialog box select to trust or allow the script to run.

Requirements

  1. Windows OS (Windows 98 may be OK, but I know Windows 2000 + will work.)
  2. Windows Scripting Host (You may already have it installed. If not do a search on Microsoft's Web Site.)

Hope this helps.





thomaso
thomaso
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 1
What if the stored procedures are encypted? I think if the utility can allow backup and restore only the partial components of DB such as stored procedures, triggers, view, tables, then it will be great. Anyone have any idea?
Stephen Carter-394501
Stephen Carter-394501
Forum Newbie
Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)

Group: General Forum Members
Points: 8 Visits: 10
BRILLIANT! Thanks!
nick.welham
nick.welham
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 Visits: 86
Thank you! I have have been looking for something to dump out the SPROCS for months and this works perfectly.
ken.trock
ken.trock
SSChasing Mays
SSChasing Mays (645 reputation)SSChasing Mays (645 reputation)SSChasing Mays (645 reputation)SSChasing Mays (645 reputation)SSChasing Mays (645 reputation)SSChasing Mays (645 reputation)SSChasing Mays (645 reputation)SSChasing Mays (645 reputation)

Group: General Forum Members
Points: 645 Visits: 1730
Wow, found this 4 years later! A helpful way to quickly get our procs and tables saved into text files off to a backup drive.

Thanks,
Ken
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search