Source Control Scripting in SC ver3
mdgraves
Posts: 53
When I first link to a new database in SC ver3, and add my dbase to Source Control, the program scripts out the objects. How can I control the script template?
Example.
I want each object script to have pre-steps to test/DROP...CREATE
IF OBJECT_ID('<<###>>') IS NOT NULL
DROP PROCEDURE <<###>>
GO
CREATE PROCEDURE <<###>>
Example.
I want each object script to have pre-steps to test/DROP...CREATE
IF OBJECT_ID('<<###>>') IS NOT NULL
DROP PROCEDURE <<###>>
GO
CREATE PROCEDURE <<###>>
Comments
You could however, if you wanted to create a migrations script that performed a DROP IF EXISTS etc. on the entire DB.
HTH!
Pete
Red Gate Software Ltd
+44 (0)870 160 0037 ext. 8569
1 866 RED GATE ext. 8569
These creation scripts are saved in source control for the sole purpose of defining the state of the schema. These scripts are not designed to be executed.
If you want to deploy from these scripts, you should use SQL Compare Pro to generate the script. This has an option to add a drop/create to the deployment script.
David Atkinson
Product Manager
Red Gate
Product Manager
Redgate Software
I was under impression Source Control scripts were OK for execution, and I have tested it as link to get scripts for all of my schema and objects into TFS source control, and as interface between TFS and SSMS.
Our standard is to use DROP & CREATE statement combinations, as opposed to ALTER. This factors into 'creation date' and system auditing. On the DBA team, when development (who owns the user databases) sends us a case to promote, we use the scripts that hopefully they are managing in TFS..
Will the Source Control tool be a stand along product, or a bolt-on for SQL Compare Pro?
- Regards,
Martin Graves
Database Technical Lead
Georgia-Pacific Building Products LLC
Please explain the logic behind the creation date and system auditing. I'd be interested to understand this further.
Both SQL Source Control and SQL Compare Pro are standalone tools, but they complement each other a lot when used together. SQL Compare Pro is the supported mechanism to deploy from source controlled scripts. This is recommended over executing the CREATE statements.
David
Product Manager
Redgate Software
In the past, queries on the "sysobjects" table for the "creation" date have been utilized by auditors to track when objects changed in user database, then in turn look for change documentation for that object and date. No other date column in table works correctly (per MS). The ALTER by-passes this date field, therefore creating an untrackable event.
I haven't checked this fact using the newer 'system views' (sys.objects), but willing to be it is same.
David
Product Manager
Redgate Software