Unix Technical Forum

Storing SQL Server 2005 objects and queries in Perforce

This is a discussion on Storing SQL Server 2005 objects and queries in Perforce within the SQL Server forums, part of the Microsoft SQL Server category; --> We are trying to use source control to store our database objects and queries in Perforce. The general idea ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-01-2008, 01:10 PM
d.grabov@gmail.com
 
Posts: n/a
Default Storing SQL Server 2005 objects and queries in Perforce

We are trying to use source control to store our database objects and
queries in Perforce. The general idea is to produce scripts which
create all objects in the DB and then store the SQL in source control.
Has anyone done this before and can suggest some advice? Alternatively
if anyone has other methods for using source control on a database,
could you please let me know?

Also, is there any automated way of extracting individual scripts for
object creation from the database?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-01-2008, 01:11 PM
Erland Sommarskog
 
Posts: n/a
Default Re: Storing SQL Server 2005 objects and queries in Perforce

(d.grabov@gmail.com) writes:
> We are trying to use source control to store our database objects and
> queries in Perforce. The general idea is to produce scripts which
> create all objects in the DB and then store the SQL in source control.


That's a very good idea!

> Has anyone done this before and can suggest some advice? Alternatively
> if anyone has other methods for using source control on a database,
> could you please let me know?


We have used Source Control for our SQL code for more than 10 years,
although we are using SourceSafe and not Perforce. Over the years, we
have developed some tools around this, which by the time have become
quite versatile. But as a start, BAT files and OSQL or SQLCMD can take
you a long way. Just don't forget the -I option to enable quoted
identifiers!

> Also, is there any automated way of extracting individual scripts for
> object creation from the database?


This can be done with DMO on SQL 2000 and SMO on SQL 2005. But once you
have you code under source control, you should not script from the
database. The database is the place where you deploy your binaries.

--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-01-2008, 01:11 PM
Mork69
 
Posts: n/a
Default Re: Storing SQL Server 2005 objects and queries in Perforce

As Erland says, it's a very good idea to store your SQL object under
source control. We have written tools to make the process of keeping
your changes under source control and propagating them to your test
and production environments simple and straightforward. Please see
www.dbghost.com for more details.

Some great advantages of this way of doing things are:

1. A 100% audit trail of who changed what, when and why (source
control history)
2. Scales to hundreds or even thousands of developers
3. Saves developer time writing upgrade or delta scripts - the tool
does it for you
4. SQL changes can be properly synchronized with the other code
changes via changelists (atomic checkin)
5. Branches are easily compared for differences when you are comparing
the object CREATE statements rather than hand coded ALTER scripts.

I hope you like our approach

Regards,

Malcolm

On Jan 29, 11:48 am, d.gra...@gmail.com wrote:
> We are trying to use source control to store our database objects and
> queries in Perforce. The general idea is to produce scripts which
> create all objects in the DB and then store the SQL in source control.
> Has anyone done this before and can suggest some advice? Alternatively
> if anyone has other methods for using source control on a database,
> could you please let me know?
>
> Also, is there any automated way of extracting individual scripts for
> object creation from the database?


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:05 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com