From the course: Program Databases with Transact-SQL

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Challenge: Use function in a stored procedure

Challenge: Use function in a stored procedure - SQL Server Tutorial

From the course: Program Databases with Transact-SQL

Start my 1-month free trial

Challenge: Use function in a stored procedure

(upbeat music) - [Illustrator] For the second challenge of this course, I'd like you to try your hand at writing and executing a stored procedure. In the chapter three folder of the exercise files is a file called 03_06_Challenge-start.sql. This file will get you started and it will contain a command to create a new table called Sales.customerAccountAudit. Once you've created that table, I'd like you to write a stored procedure with an input parameter that allows end users to search for customer records. The stored procedure should do three things. First, it'll return some information from these sales.customers table for a customer identified by the input parameter. Second, return some information from the sales.orders table for the same customer. Finally, write a new row to the customer account audit table that we just created that logs the activity. The end user should not be alerted that the search activity that they just performed has been logged. For this challenge, these…

Contents