Hi All,
I have the TFS MSSCCI installed, now what? How do I use it to put say like a stored procedure under source control?
Thanks, rodchar
Hi All,
I have the TFS MSSCCI installed, now what? How do I use it to put say like a stored procedure under source control?
Thanks, rodchar
The best way to version control sprocs is to make a SQL script that installs the stored procedure, perhaps of the form
if object_id ('FooSproc') is not null
drop procedure FooSproc
go
Create procedure FooSproc
[ . . . ]
go
Put the scripts in source control.
Versioning and releasing a larger body of stored procedure code
You may also need to sort out a means of compiling multiple scripts into a single installer for sprocs. A quick and dirty way that actually works quite well is to use the C preprocessor and files with a bunch of #include statements. The C preprocessor comes with Visual Studio or the free SDK that you can download from Microsoft's web site.
-- =========================================================================
-- === Installer file for FooApp sprocs ====================================
-- =========================================================================
--
-- THIS IS GENERATED CODE. EDITS WILL BE OVERWRITTEN.
--
-- =========================================================================
--
#include "Foo.sql"
#include "Bar.sql"
#include "Wibble.sql"
With a bit of scripting you can make a release manager that lets you check out all of the sprocs for a given version of your application and install that version into a database. Of course, don't forget to update the include file or the installer will miss anything not included.
In order to use the C preprocessor you need to set up your environment. Visual studio ships with a batch file to do this that will typically end up installed somewhere like:
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\vcvarsall.bat
You need to run the batch file to set up the environment, and then you can run the C preprocessor with an incantation like:
cl /EP DB\DB.inc > Build\DB\DB.sql
This will read an include file, include all of the files it references and then write to stdout; you can redirect stdout anywhere that takes your fancy. Note that the C preprocessor is recursive and you can include other include files.