Source Code Management and Database Deployment - Managing Create Scripts in Visual Studio .NET
(Page 3 of 9 )
When Create scripts are locked, you can open them for viewing in the editor, but Visual Studio .NET will prevent you from changing them until you check them out.
To view a Create script, right-click the script you want to review and select Open. Visual Studio .NET opens a copy of the Create script but marks it “read-only.”
The following list demonstrates how to change a stored procedure:
- Close the window with the read-only version of the Create script.
- Right-click the script for a stored procedure and select Check Out from the pop-up menu. The program prompts you for confirmation and comment:
- Make some trivial change to the stored procedure.
- Save the changes (File | Save) in the change file.
- Right-click the file and choose Check In from the menu. The program prompts you for confirmation and comment again.
TIp
Take the time to describe what changes you made in your comment. This will be incredibly helpful if some detective work is required later.
- Click Check In. Visual Studio .NET saves the changes in Visual SourceSafe and locks the Create script.
At this point, the stored procedure does not yet exist in SQL Server. You must right-click the file and select Run to add it to the default database. Visual Studio .NET opens the Database Output pane to show the results (and possibly errors) of the execution (see Figure 11-3).

Figure 11-3. Database Output pane of the Create script
executed against the server
NOTE
Unfortunately, this solution does not prevent another developer from using some other tool to change a database object directly in the database. You can even open Server Explorer in Visual Studio .NET to change them without source code control. Visual SourceSafe only works through consensus. Loose cannons can still wreak havoc on your development ship.
To promote the change to another server, you can choose the Run On option in the context menu of the change script.
TIP
When I first started to use Visual SourceSafe, the directions implied by the terms “Check Out” and “Check In” sounded inverted to me. Just think of Visual SourceSafe as an actual safe from which you are taking your code and into which you subsequently return your code after you are done with it.
- Now, go back and check out the same stored procedure again.
- Open it and reverse your previous changes.
- Save the stored procedure.
- Run the Change script against the server to test it (right-click the Change script and select Run).
Assume that you are not satisfied with these changes and that you want to abandon them. (Assume that you have tested them and the result is not what you expected.) To do so:
- Select Undo Check Out from the context menu. The Visual SourceSafe Server locks the file again and uses the previous copy from Visual SourceSafe to reverse the changes in the local file.
- To reverse changes to the database, you must Run the change script again.
NOTE
Undo Checkout does not actually change any code already deployed, but merely reverses the check out process.
Next: Visual SourceSafe Explorer >>
More MS SQL Server Articles
More By McGraw-Hill/Osborne
|
This article is excerpted from SQL Server 2000 Stored Procedure & XML Programming, second edition, written by Dejan Sunderic (McGraw-Hill/Osborne, 2004; ISBN: 0072228962). Check it out at your favorite bookstore today. Buy this book now.
|
|