The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 2 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Using SQL and Northwind Database
1. Write a simple trigger that only prints a message stating that a row in the customers table has been updated and that fires only upon the execution of an update statement on the customers table.
2. Create a trigger that will run instead of the Update statement on the Suppliers table. It will fire when an Update statement is executed against the Suppliers table and will an error message saying: "Updating information in this table is not allowed" Include a statement that will fire your trigger and also a statement to drop your trigger. (Hints: There is such a thing as an "instead of trigger". Include a statement that will fire your trigger and also a statement to drop your trigger.
3.
Northwind management is concerned that someone is updating and deleting products without following proper procedures. You are asked to provide a log of all future UPDATES and DELETES performed on the products table. Unfortunately the products table does not store this information. You decide to create a log table and a trigger that will load this log table with the productid, the date and the user of the deleted or updated product. ******************************************** The user can be obtained like this: Declare @User varchar(20) Select @User = System_User Include a statement that will fire your trigger and also a statement to drop your trigger.
4. create a stored procedure called "uspListAllUserTables" that will print the names of all tables in the sys.Objects table that are user tables (ie., type = 'U'). (Hint: you will not need to return a table object - just using the print statement within the sproc will print out the tables) Include a statement to execute your stored procedure and be sure to test it to ensure it works.
-----------