564 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owls only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.
First (if you haven't already done so) run the script shown above to generate the Doctor Who training database.
The aim of this exercise (which is fully explained in the following pages) is to create a temporary table called #Characters containing all of the doctors, companions and enemies in the database. The idea is that you should be able to display these as follows:
-- show results
SELECT * FROM #Characters
ORDER BY CharacterName DESC
This should show the following rows:
The first few of the 109 "characters" in the database (giving the id number and type of each).
Start a query, and write code to delete any temporary table called #Characters:
-- get rid of any old copy of temporary table
IF object_id('tempdb.dbo.#Characters', 'U') is not null
DROP TABLE #Characters
Write an instruction to put the doctors into a new table. The syntax is:
-- create a new table containing rows from an existing table
Column1 AS NewColumnAlias1,
ColumnN AS NewColumnAliasN,
You may need to cast the character type to a 10-character string, otherwise the query will create a 6-character string to accommodate the word Doctor and crash when you try to put the word Companion in it subsequently.
Here's what you should have so far when you display the rows in your temporary table in reverse name order:
So far we have 12 doctors - time now to add some companions and enemies.
SQL Server will have created the CharacterId column as an identity column. Tell it to let you add more rows by running this line:
-- allow more identity values to be inserted
SET IDENTITY_INSERT #Characters ON
Now use two separate statements to add the companions and enemies (from the tblCompanion and tblEnemy tables respectively) into your temporary table, using this syntax:
-- append rows into existing table
INSERT INTO #Characters (
When you've finished, every time that you run your entire query it should drop any old copy of the temporary table and create a new one containing 109 rows (as shown at the start of this exercise).
Optionally, save your query as Strange bedfellows.sql, then close it down.
25 Aytoun Street