Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
546 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers 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
Search our website
We also send out useful tips in a monthly email newsletter ...
Software ==> | SQL (203 exercises) |
Topic ==> | Testing conditions (3 exercises) |
Level ==> | Relatively easy |
Subject ==> | SQL training |
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.
If you don't have a copy of the Music_01 database, follow the instructions at the following link to create it: www.wiseowl.co.uk/sql/exercises/standard/using-sql-server/5257/
Open the Albums or Singles.sql file in the folder shown above. Execute the script to create a stored procedure which can return a list of albums or singles (or both) released in a given year.
Both parameters are optional.
Currently, the procedure will return the results of all three queries regardless of what you pass into the @AlbumOrSingle parameter.
Add an IF statement so that if the word Album is given to the @AlbumOrSingle parameter, the procedure selects the list of matching albums and then uses a RETURN statement to exit.
If you want to perform multiple actions based on the result of a condition, don't forget to use a BEGIN END block.
Add another IF statement to return a list of singles and exit the procedure if the word Single is given to the @AlbumOrSingle parameter.
Add a third IF statement which returns the combined list of albums and singles and exits the procedure if the @AlbumOrSingle parameter is omitted.
Add a final statement to the procedure which shows a message if a word other than Album or Single is passed to the @AlbumOrSingle parameter.
An example of the type of message you could display.
Save and then close the scripts.
You can find other training resources for the subject of this exercise here:
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.