Main Page
 The gatekeeper of reality is
 quantified imagination.

Stay notified when site changes by adding your email address:

Your Email:

Bookmark and Share
Email Notification
TFS 2008 and Microsoft SQL Server Scripting
    Looking For Team Foundation Server 2008 Tutorials? Go here.
Looking For TFS 2008 Deleting A Team Project? Go here.


Purpose
The purpose of this tutorial is to demonstrate how to use a project in TFS 2008 enabling you to take advantage of many of the features that you normally have with SQL Server 2005 Management Studio such as interacting with databases directly to run queries, create/change scripts, and generally to directly manipulate database objects and data. Since previous tutorials covered the installation of TFS 2008 enabling users to take advantage of all the features of TFS 2008, this tutorial assumes that you have a similar configuration and therefore do not need "middleman tools" such as the "Visual Studio Team System 2008 Team Foundation Server MSSCCI Provider" found here.

STEP 1

(Enlarge)
  1. Under "File" select "New Team Project"
STEP 2

(Enlarge)
  1. Specify a name for the team project
  2. Click on the button labeled "Next >"
STEP 3

(Enlarge)
  1. Select a process template to use. I've always used "MSF for Agile Software Development - v4.2"
  2. Click on the button labeled "Next >"
STEP 4

(Enlarge)
  1. Provide a description of the team project
  2. Click on the button labeled "Next >"
STEP 5

(Enlarge)
  1. Starting out you will probably want to select "Create an empty source control folder"
  2. Click on the button labeled "Next >"
STEP 6

(Enlarge)
  1. Confirm the settings and click "Finish" when you are ready to proceed
STEP 7

(Enlarge)
  1. Now that we have a team project that we can place all SQL Server related scripts and projects inside of, let's create a SQL project for a forums database
  2. Under "File" select "New Project"
STEP 8

(Enlarge)
  1. Under "Project types:" expand "Other Project Types"
  2. Select "Database"
  3. Under "Templates:" ensure that "Database Project" is selected
  4. Where it prompts for a name of the database project, provide a name
  5. NOTE: Ensure that "Add to Source Control" is checked
STEP 9

(Enlarge)
  1. You will be prompted to choose a data source for the database project
  2. In our case select "Microsoft SQL Server"
STEP 10

(Enlarge)
  1. The "New Database Reference" pane will appear
  2. You will need to specify the name of the Microsoft SQL Server that will be connected to
  3. Under the section "Log on to the server" choose the method that the project will use to connect to the server
  4. Under "Connect to a database", select the name of the database that the database project will be interacting with
STEP 11

(Enlarge)
  1. If you need to test your connection, you can click the button labeled "Test Connection"
STEP 12

(Enlarge)
  1. Confirm the details and click on the button labeled "OK"
STEP 13

(Enlarge)
  1. After confirmation, The Solution Explorer and Source Control Explorer would look something like this
STEP 14

(Enlarge)
  1. Now it's time to add an SQL Script to the database project
  2. Under the Solution Explorer (where you can create folders or use existing ones) right-click on the folder labeled "Queries"
  3. Select "Add SQL Script" from the popup menu
STEP 15

(Enlarge)
  1. Under "visual Studio installed templates" select "SQL Script"
  2. Next to "Name:" provide a name for the SQL Script that will be intuitive
  3. Click the button labeled "Add"
STEP 16

(Enlarge)
  1. Now, let's add that SQL code! I would recommend having one block of SQL per script page just so that it is easier to track changes being made to SQL code
STEP 17

(Enlarge)
  1. Now that you've got some SQL script added to the project, there are a few different ways that you can have that code executed
  2. Under Solution Explorer you can right-click on the .SQL page and select "Run" from the popup menu...
STEP 18

(Enlarge)
  1. ...or you can do it the "old school" way and highlight the code, right-click and select "Run Selection" from the popup menu
STEP 19

(Enlarge)
  1. After execution, the Output pane will show the results of the code you executed
STEP 20

(Enlarge)
  1. After you have added the script(s), be sure to right-click on the .SQL(s) and select "Check In..." from the popup menu
STEP 21

(Enlarge)
  1. Be sure to add at least a comment about the .SQL you are checking into Team Foundation Server
  2. When finished, click on the button labeled "Check In"
STEP 22

(Enlarge)
  1. As a side note, if you expand "Server Explorer" you fill discover that you have many options similar to SQL Server 2005 Management Studio
About Joe
Find Out Now!