This repository contains the complete solution to the Level B SQL Task, assigned as part of the Week 2 deliverables during the Summer Internship Program at Celebal Technologies.
InsertOrderDetails: Validates stock and inserts order lines.UpdateOrderDetails: Updates fields with NULL-safety and adjusts inventory.GetOrderDetails: Fetches order line items by OrderID.DeleteOrderDetails: Removes a specific product from an order with validation.
fn_FormatDate_MMDDYYYY: Converts DATETIME to MM/DD/YYYY.fn_FormatDate_YYYYMMDD: Converts DATETIME to YYYYMMDD.
vwCustomerOrders: Shows order details with customer and product info.vwCustomerOrders_Yesterday: Filters the above view for yesterday's orders.MyProducts: Lists non-discontinued products with vendor and category info.
trg_InsteadOfDeleteSalesOrder: Deletes dependent order details before order.trg_CheckStockBeforeInsert: Prevents insert when stock is insufficient and updates inventory on success.
- SQL Server 2022 Express / Developer Edition
- SQL Server Management Studio (SSMS)
- AdventureWorks2022 OLTP Sample Database
โ๏ธ All queries are designed and tested using the default schema structure of the AdventureWorks2022 database available from Microsoft's official GitHub repository along with Custom Sample Database Schema.
- Microsoft SQL Server (2019 or later)
- SQL Server Management Studio (SSMS)
AdventureWorks2022OLTP database restored on your SQL Server
- SQL Server 2022 Express / Developer Edition
- SQL Server Management Studio (SSMS)
- AdventureWorks2022 OLTP Sample Database
โ๏ธ All queries are designed and tested using the default schema structure of the AdventureWorks2022 database available from Microsoft's official GitHub repository.
๐ AdventureWorks2022/
โ โโโ ๐ Functions/
โ โ โโโ FormatDate_MMDDYYYY.sql
โ โ โโโ FormatDate_YYYYMMDD.sql
โ โโโ ๐ Stored procedures/
โ โ โโโ DeleteOrderDetails.sql
โ โ โโโ GetOrderDetails.sql
โ โ โโโ InsertOrderDetails.sql
โ โ โโโ UpdateOrderDetails.sql
โ โโโ ๐ Triggers/
โ โ โโโ trg_CheckStockBeforeInsert.sql
โ โ โโโ trg_InsteadOfDeleteSalesOrder.sql
โ โโโ ๐ Views/
โ โโโ MyProducts.sql
โ โโโ vwCustomerOrders.sql
โ โโโ vwCustomerOrders_Yesterday.sql
โ
โโโ AdventureWorks_LevelB_Task.sql
โ
โโโ Level B Task.pdf
โ
โโโ README.md