https://github.com/ani811625/csi-assignment2
📊 SQL queries built on the AdventureWorks2022 database. Includes stored procedures, views, triggers, functions, and sample test queries for an order management system.
https://github.com/ani811625/csi-assignment2
adventureworks microsoft-sql-server sql
Last synced: 8 months ago
JSON representation
📊 SQL queries built on the AdventureWorks2022 database. Includes stored procedures, views, triggers, functions, and sample test queries for an order management system.
- Host: GitHub
- URL: https://github.com/ani811625/csi-assignment2
- Owner: Ani811625
- Created: 2025-06-14T07:32:28.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-15T07:58:07.000Z (about 1 year ago)
- Last Synced: 2025-08-20T11:45:58.330Z (10 months ago)
- Topics: adventureworks, microsoft-sql-server, sql
- Language: TSQL
- Homepage:
- Size: 794 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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
```plaintext
📂 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