From the course: Complete Guide to Advanced SQL Server
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Create a trigger to add points to player records - SQL Server Tutorial
From the course: Complete Guide to Advanced SQL Server
Create a trigger to add points to player records
The first task in our Game Score database project is to synchronize the points awarded from our ScoreEvents table, and then add those points to the scores recorded in the Players table. And we can do that with a trigger. And that's what we're asked to create here for this first part. So I'm going to go ahead and get started. I've got my database set up over here and the two tables created from the prior movie. I'm just going to execute the script as we have it here on the screen here, just to take a look at the starting state of both of those tables. So at the top here, we've got the ScoreEvents table. There's no records yet. And this is where we're going to store the score ID, the date that the score was earned, the player that earned those points, as well as the number of points that they earned. And then our trigger that we're about to write is going to take whatever the score is and add it to the player score that's recorded in the Players table. And so that's our goal is to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
GameScore database final project setup2m 38s
-
(Locked)
Create a trigger to add points to player records6m 30s
-
(Locked)
Calculate global score with custom function4m 7s
-
(Locked)
Write a stored procedure: Part 16m 19s
-
(Locked)
Write a stored procedure: Part 24m 44s
-
(Locked)
Add error handling and test the system: Part 16m 14s
-
(Locked)
Add error handling and test the system: Part 25m 52s
-
-