Skip to content

๐Ÿ“Š SQL queries built on the AdventureWorks2022 database. Includes stored procedures, views, triggers, functions, and sample test queries for an order management system.

Notifications You must be signed in to change notification settings

Ani811625/CSI-Assignment2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

35 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

CSI-Assignment2

๐Ÿ’ผ Celebal Technologies Internship โ€“ Level B SQL Assignment

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.


โœ… Overview of Implemented SQL Components

๐Ÿ”ง Stored Procedures

  • 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.

๐Ÿงฎ Scalar Functions

  • fn_FormatDate_MMDDYYYY: Converts DATETIME to MM/DD/YYYY.
  • fn_FormatDate_YYYYMMDD: Converts DATETIME to YYYYMMDD.

๐Ÿ‘๏ธ Views

  • 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.

๐Ÿ”ฅ Triggers

  • trg_InsteadOfDeleteSalesOrder: Deletes dependent order details before order.
  • trg_CheckStockBeforeInsert: Prevents insert when stock is insufficient and updates inventory on success.

๐Ÿ› ๏ธ Technologies & Tools Used

  • 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.


๐Ÿ’พ How to Use This Project

1. Prerequisites

  • Microsoft SQL Server (2019 or later)
  • SQL Server Management Studio (SSMS)
  • AdventureWorks2022 OLTP database restored on your SQL Server

2. Execution Steps

-- Run the script AdventureWorks_LevelB_Task.sql

๐Ÿ› ๏ธ Technologies & Tools Used

  • 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.


๐Ÿ“ Repository Structure

๐Ÿ“‚ 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

About

๐Ÿ“Š SQL queries built on the AdventureWorks2022 database. Includes stored procedures, views, triggers, functions, and sample test queries for an order management system.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages