• subscribe
March 22, 2006 12:00 AM

Visual SourceSafe

Knowing who did what and when
SQL Server Pro
InstantDoc ID #49474

Let's walk through a simple example of how to create a Solution, execute it on the server, and check it in to VSS.

  1. When you create a new query, SQL Server Management Studio automatically creates a blank Solution (with 0 projects).
  2. Add a project to the Solution. In the Solution Explorer (which is a component of SQL Server Management Studio), right-click on the Solution name and select Add new project. Select SQL Server Scripts and rename the file.
  3. Write your T-SQL code in the query window.
  4. Save the Solution, project, and SQL files in your working folder.
  5. Execute your T-SQL code on the SQL server. (This step isn't necessary if your code is an ad hoc query.)
  6. To add a SQL file to a project, right-click on the project name in Solution Explorer, then select Add existing file. Select the SQL file from your working folder.
  7. To add the Solution to Source Control, access the main VSS menu. On the VSS toolbar, select the File option, Source Control, then Add Solution to Source Control from the drop-down menu. After you add the file to Source Control, the Solution, Project, and Queries folders display a lock symbol next to each filename in Solution Explorer. The lock symbol indicates that the file is under source control and is read-only.

You can continue to place additional TSQL code under the Queries folder in your project.You can add each query to Source Control as it is completed by right-clicking on the project and selecting Add existing item.You need to check out the Solution file and project file from VSS before you can add more files;VSS prompts you to check out the project files when you add a new file.

Modifying a Stored Procedure
Follow these steps to check out a file for editing, check it back in to VSS, and execute a file comparison.

  1. Access the main VSS menu. On the VSS toolbar, select File, Source Control, Open from Source Control. VSS prompts you for your VSS user ID and password.
  2. If you have files in your working folder, VSS prompts you to verify whether you want to overwrite the changes. Another option is to open the Solution file directly from your working folder and select the Get Latest Version menu item to retrieve the latest version of the files from the VSS database.
  3. Right-click on the SQL code that you want to update and select Check-out for edit. VSS prompts you to check out the project and Solution files and enter an explanation for checking out the file for historical purposes.
  4. After the file has been checked out, you'll see a green icon next to the filename in the VSS menu.This icon indicates that the file is no longer read-only.
  5. After you finish making changes to the TSQL code, you can execute the code on the server and check the file in to VSS. To do so, right-click on the filename and select Check-in.VSS prompts you to check in the project and Solution files as well as the SQL file.You could keep the project and Solution files checked out if you anticipate having to make additional changes to other queries in the Solution.
  6. To scan the history of the query that you checked in to see what was changed, right-click the filename and select History. Select the two versions of the file to compare, then select Diff.VSS to display a two-pane window that lists the differences found in the two versions of code. Code that has been deleted appears in blue, code that has been edited appears in red.

As you can see, after you set up a Solution in VSS, it's easy to retrieve the file to make changes.With the integration of VSS in SQL Server 2005, these tasks have become seamless.

Is Your Environment Under Control?
Version control isn't just about software: It's also about processes that are enabled by the right software.VSS provides SQL database developers in small-to-midsized software companies with a tool that can centrally manage all of the enterprise's code that's readily accessible from the SQL Server interface. Having the ability to centrally manage file-version control helps to simplify common tasks such as code reviews, project management, source-code change auditing, and backups. If used properly, version-control procedures and VSS should help your development team avoid costly mistakes such as overwriting source code, thus protecting the integrity of your data and improving the productivity of your development team.



ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here