Installation:
There are 2 steps to installing __SC
A description of the automated installation tool can be found here
Walkthru:
A typical usage scenerio:
The user starts SSMS , creates a definition for a new stored procedure and runs it, For example:
Create Procedure TestProcedure as begin Select 1 end
in the message window at the bottom of SSMS __SC responds with this:
>SC>> Object record for TestProcedure created. >SC>> Checkout Success.(Status = SUCCESS_AVAIL_CREATED) run ( __SC 'TestProcedure' )to check in >SC History for TestProcedure
at this point the stored procedure has been added to the __SC catalog and is checked out to the current user. The user can now edit and alter the stored procedure as many times as wanted.
If another user wants to edit the same stored procedure and attempts to run a alter statement on the stored procedure , __SC will prevent them and will respond with the following message:
>SC>> ::ERROR:: Object TestProcedure already checked out by Vista11256\TestUser
Object change rolled back due to source control error
Msg 3609, Level 16, State 2, Procedure TestProcedure, Line 4
The transaction ended in the trigger. The batch has been aborted.
When the original user is finished editing and testing change they can check it in by executing the following line somewhere in a SSMS window
__SC 'TestProcedure'
__SC will save a new version of the stored procedure and mark the object as checked in and respond with the following message
>SC>> Object TestProcedure Checkin succesfull
To see a history of all actions against TestProcedure you can execute
__SC 'HISTORY','TestProcedure'
UserName |
AtDateTime |
ActionType | Description | Version |
Vista11256\TestUser | 2011-01-01 15:38:49.073 | CHECKIN | 2 | |
Vista11256\TestUser | 2011-01-01 15:31:19.760 | AVAIL_CREATED | 1 |
Checkouts last for 24 hours (you can "Grab" a checkout before that if need)
Get Latest (or at least proving you have the latest version)
After the original user checks in his changes another user can checkout the object and continue working on it.
However that user needs to "GetLatest" - by proving that he has the latest version by first submitting a alter with the exact definition currently in the the database, if they submit a modified defintion they will receive the following message
>SC>> ::ERROR:: You do not seem to have the correct version of object TestProcedure.
To confirm this and to successfuly checkout you must first issue a alter on the object with the current definition.
You can quickly retreive the definition by running the following "Object_Definition(Object_ID('TestProcedure'))
Object change rolled back due to source control error Msg 3609, Level 16, State 2, Procedure TestProcedure, Line 4 The transaction ended in the trigger. The batch has been aborted.