Simple stored procedure with input

Easy
3 views 23 Jan 2026
Create a stored procedure sp_add_department(p_id, p_name) that inserts into Departments....

Procedure to update salary

Easy
3 views 23 Jan 2026
Create procedure sp_hike_salary(p_emp_id, p_percent) that increases salary for that employee....

Procedure with output parameter

Easy
2 views 23 Jan 2026
Create sp_order_total(p_order_id, OUT p_total) that returns sum(qty*price) from OrderItems....

Procedure to clean old logs

Easy
2 views 23 Jan 2026
Create sp_delete_old_logs(p_days) that deletes from LoginLogs older than p_days....

Call a procedure

Easy
2 views 23 Jan 2026
Show how to call sp_order_total for order 7001....

Procedure with transaction inside

Medium
3 views 23 Jan 2026
Create sp_transfer_funds(p_from, p_to, p_amt) to transfer money between two accounts. If the sender does not have enough balance, rollback the transaction so nothing changes....

Procedure with cursor-like loop (simple)

Medium
2 views 23 Jan 2026
Create sp_mark_low_stock(p_limit) that sets Products.low_stock=1 when qty_on_hand < p_limit....

Procedure returning result set

Medium
2 views 23 Jan 2026
Create sp_top_customers(p_n) that returns top N customers by total spend....

Procedure with input validation

Medium
3 views 23 Jan 2026
Create sp_add_coupon(code, discount) that validates discount first. If discount is not in 1..80, raise an error; otherwise insert the coupon....

Procedure to rebuild summary table

Medium
2 views 23 Jan 2026
Create sp_refresh_daily_sales that truncates DailySales and re-inserts aggregated totals from Orders....

Idempotent procedure behavior

Hard
4 views 23 Jan 2026
Make sp_add_department safe if dept_id already exists: update name instead of failing....

Procedure for batch price update with audit

Hard
2 views 23 Jan 2026
Create sp_discount_category(p_category, p_percent) that updates product prices and writes an audit row per product into PriceAudit(product_id, old_price, new_price, changed_at)....

Procedure to detect and return duplicates

Hard
3 views 23 Jan 2026
Create sp_find_duplicate_emails that returns emails appearing more than once in Users....

Procedure with retry logic idea

Hard
2 views 23 Jan 2026
When inserting into Payments, deadlock may happen. Write a stored procedure outline that retries 3 times (simple loop)....

Procedure to place an order with items table variable

Hard
2 views 23 Jan 2026
Create sp_place_order(p_customer_id, p_order_id) that inserts an order, then inserts all rows from TempOrderItems into OrderItems for that order in one go....