Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12345»»»

Version Control your Stored Procedures Expand / Collapse
Author
Message
Posted Wednesday, May 5, 2010 9:34 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Yesterday @ 3:19 AM
Points: 338, Visits: 1,421
Comments posted to this topic are about the item Version Control your Stored Procedures
Post #916639
Posted Thursday, May 6, 2010 1:05 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, September 12, 2012 8:44 PM
Points: 30, Visits: 145
Just a small suggestion - please consider EXTENDED properties for DB objects (including Stored Procedures), by using them in a key-value fashion you could avoid a lot of text processing.

Regards from DownUnder.
Post #916695
Posted Thursday, May 6, 2010 1:40 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, December 13, 2012 9:44 AM
Points: 4, Visits: 30
Just a small concern...

As far as experience and memory serves, sp_helptext is not a reliable source for recreating SQL server objects. SQL management objects are the preferred source.

Changes to an object and/or metadata may render sp_helptext outdated - the script used to create the original object may not reflect the object in its current state. I seem to remember a case where the sp_helptext record was blatantly incorrect after a (?) designer edit.

Does anyone have a concise view of when this may occur, and whether stored procedures are for practical purposes immune to these cases?

Post #916710
Posted Thursday, May 6, 2010 4:19 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Yesterday @ 11:08 AM
Points: 577, Visits: 2,502
I really enjoy seeing scripts like this, since the whole topic of scripting is fascinating. What I really like about this is that someone has gone ahead and brewed a solution that fits their requirements like a glove. It is neat, because it will work with any version of SQL Server 2000+.

I wouldn't like anyone to think that this is a recommended general solution, though. SMO is the way to go! (I still occasionally use DMO)



Best wishes,

Phil Factor
Simple Talk
Post #916779
Posted Thursday, May 6, 2010 4:20 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, March 31, 2014 8:17 AM
Points: 110, Visits: 182
I also had similar issues with sp_helptext and eventually found a way of scripting objects using
Microsoft.SqlServer.Management.Smo.Scripter in Powershell.. this has the advantage that it handles all types of objects including everything from logins to linked-servers, mail profiles, etc, and can take advantage of easy iteration possible in powershell.

I've written a skeleton (and, disclaimer; is not warranted in any way) ps script that captures relevant source/schema stuff in SQL Server, if anyone's interested. Obviously it can be adjusted to taste for extended properties etc (which I turn off by default) and should be tweaked to expose specific properties relevant to only certain objects.

Link here
http://wp.me/pje2P-l

I also have a wrapper script that iteratively runs it for each database on the server, and a server-objects script that captures mail profiles, accounts etc, for anyone interested.

Regards,
Mike

Post #916781
Posted Thursday, May 6, 2010 6:41 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Yesterday @ 7:32 PM
Points: 15,517, Visits: 27,895
I'm with Phil on this one. It was a good read and an interesting solution, but way more difficult than needed since SMO can do so much of the work.

That said, yee hah! for so much discussion around getting database code into source control. I think this is a huge whole in lots of shops these days.


----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of: SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #916882
Posted Thursday, May 6, 2010 6:49 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: 2 days ago @ 8:36 AM
Points: 4,319, Visits: 6,112
Or you can simply use ApexSQL Edit, which has some very spiffy built-in source code control functionalilty - among many other features.

Disclaimer: I have a close relationship with Apex, use their products and recommend them to my clients. Also, if you care to you can mention TheSQLGuru sent you you will get a discount and my daughter will get a few coins for her college fund.


Best,

Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru at GMail
Post #916889
Posted Thursday, May 6, 2010 6:53 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, November 19, 2013 7:51 AM
Points: 43, Visits: 218
Good article. I always like to see/hear how others are using version control on their databases. Currently, we version all objects not just stored procedures, functions and triggers. There are inherent issues with this obviously, but we have tried to figure out ways around them that fit our particular needs. We are even working on a way to create automatic builds of our database changes to a testing environment without using compare tools. I'd love to hear if others have successfully used a version control solution to maintain database updates as well.

Thanks again for the article

J. Baxter
Post #916896
Posted Thursday, May 6, 2010 7:05 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, March 31, 2014 8:17 AM
Points: 110, Visits: 182
Automated deployments of stored-procs is relatively easy, but anything that involves a table schema change for example kind of makes the whole approach a bit complex and prone to problems. Also, it becomes much harder if you are building routines that need to be created in a specific order- we've toyed with creating dependencies but never got it working satisfactorily.

More useful for us in our small shop was detecting unauthorised/unexpected changes to our database objects, and providing a good audit of objects altered to tie into our change control process.

Using SMO we've been able to version most objects quite easily and build a daily source copy and an associated job to compare the output to a VC'd baseline, noting differences.

It's also made capturing changes between a development environment and production environment a lot easier- script both to two folders and run a winmerge or similar comparison tool to see what ammendments have been made- although as noted above, syncing the changes almost always is easier to handle the "long" way for our relatively simple db.
Post #916912
Posted Thursday, May 6, 2010 7:11 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Sunday, June 8, 2014 11:23 PM
Points: 129, Visits: 216
I have to agree with some of the comments here particularly on the principal on version control however and at the risk or creating some controversy, I would question the value of the solution provided other than it fitted exactly what one person required and it managed to generate some discussion.

Phil was spot on with recommending that SMO was the way to go and while I agree with that for this particular problem my underlying point is that the solution to a problem should really be based on sound technical knowledge of the tool set and the most appropriate elements of that tool set to be used to provide the solution.

Powershell was also mentioned and this in conjunction with SMO/SQLPSX can give you a scripter in one line of code. You cant get much simpler than that and while not very useful as it stands it does serve as an example of the value in knowing what is available.

-- Script all tables in the adventureworks database on the default instance on the local server
Get-SqlDatabase "(localserver)" "adventureworks" | Get-SqlTable | Get-SqlScripter

Articles like this just make me question just how much knowledge the writer has with the tool set we all use on a day to day basis.
Post #916918
« Prev Topic | Next Topic »

Add to briefcase 12345»»»

Permissions Expand / Collapse