views:

102

answers:

4

My Application Database Without Project and without Source safe, i planned to make my DB to be as project and add it to TFS, but I have no idea how to script the stored procedures, Triggers, Views, Functions, and what is the best practice to Make Update Script for All My stored procedures, Triggers, Views, and Functions to My customers DB.

A: 

The best procedure (IMHO) is to manually maintain a strict version of your schemas. Then when you need to make changes you write a delta script to move from one version to the next. I suggest you write the DDL scripts by hand -- you can make them concise and comment them.

Hassan Syed
A: 

I've found a good way to get SQL scripts into SCM from an existing database is to use SMSS's "export all to script" option or whatever it's called, can't remember now.

Then every other change you add the change script into your SCM with a different version number in the file name.

Every release (or set cycle depending on your development/release methodology) you apply all change scripts, then re-script the entire database, tag it, and start again.

Andy Shellam
+1  A: 

You can use a tool like Visual Studio Team System for database architects, take a look at Running static code analysis on SQL Server database with Visual Studio Team System for database architects it will show you how to import the data, disregard the static code analysis that comes later it does not apply to your question

SQLMenace
That article is quite rubbish (I won't -1 though), and what does this have to do with the OP's question ? If static code analysis is the holy grail then you should at least explain why this is relavant to the OP's (cryptic) question.
Hassan Syed
in the article it clearly states how to import the objects, he asked "how to script the stored procedures, Triggers, Views, Functions" the static code analysis doesn't apply to his question but the first couple of steps do
SQLMenace
A: 

The best way to do it - save the database in TFS as set of database creation script, i.e. MyTable table should be added to TFS as MyTable.sql file (CREATE TABLE...) etc. We are using SQL Examiner to do this - see the following article: How to keep your database under version control

We are working with SVN and I never tested SQL Examiner with TFS, but I know that the tool supports TFS.

SQLDev