Documente Academic
Documente Profesional
Documente Cultură
The purpose of this practice is to enable you to create and drop triggers by using
Transact-SQL.
Objectives
In this practice, you will:
Instructions
Log on to the virtual machine with the user name Student and the password
Pa$$w0rd.
Value
Server type
Database Engine
Server name
MIAMI
Property
Value
Authentication
Windows Authentication
6-19
Value
Server name
MIAMI
Authentication
Windows Authentication
6-20
SELECT ModifiedDate
FROM HumanResources.Employee
WHERE EmployeeID = 1
8. Verify that the DELETE operation is unsuccessful and that the trigger returns an
error.
9. Close SQL Server Management Studio. Click No if prompted to save any files.
6-21
6-33
Lab Setup
For this lab, you will use the available virtual machine environment. Before you begin the
lab, you must:
Log on to the virtual machine with the user name Student and the password
Pa$$w0rd.
Lab Scenario
The Human Resources department has decided that it wants to keep a historical record of
job candidates so that it can contact past unsuccessful candidates if new positions come
up, and compare the information provided by candidates if they apply for different
positions over time. After consulting with the Human Resources team, the senior
database developer has decided a new table is required to store this historical information.
The senior database developer has provided you with the Transact-SQL to create the
HumanResources.JobCandidateHistory table. The senior database developer has asked
you to:
6-34
Create a SQL Server Scripts project for the modifications by using SQL Server
Management Studio, and then store the project in the D:\Labfiles\Starter folder.
Additional Information
When performing database development tasks, it can be helpful to use SQL Server
Management Studio to create a SQL Server Scripts project, and use it to document the
Transact-SQL code necessary to re-create the solution if necessary.
Use the following procedure to create a SQL Server Scripts project:
1. Open SQL Server Management Studio, connecting to the server you want to manage.
2. On the File menu, point to New, and then click Project.
3. Select the SQL Server Scripts template and enter a suitable name and location for
the project. Note that you can create a solution that contains multiple projects, but in
many cases a single project per solution is appropriate.
Use the following procedure to add a query file to a project:
1. On the Project menu, click New Query, or in Solution Explorer, right-click the
Queries folder, and then click New Query. If Solution Explorer is not visible, on the
View menu, click Solution Explorer.
2. When prompted, connect to the server on which you want to execute the query. This
will add a connection object to the project.
3. To change the name of the query file from the default name (SQLQuery1.sql), rightclick it in Solution Explorer and click Rename.
Although you can perform all database development tasks by executing Transact-SQL
statements, it is often easier to use the graphical user interface in SQL Server
6-35
6-36
Supporting information
1.
2.
3.