SQL Server Tutorial: Sample Database, Tables and Data
Run this script first: every other SQL lesson on this site uses these tables.
It creates the database SqlLearningDb with a small "online store" model:
Departments 1 ---< Employees >--- Employees (ManagerID = self join)
Customers 1 ---< Orders >---1 Employees (sales person)
Orders 1 ---< OrderItems >---1 Products >---1 Categories (self hierarchy)
Sales (flat daily sales table, great for window functions)
Data has some "special cases" on purpose so that joins are interesting:
- Department 8 (Research) has NO employees
- Employee 24 (Intern) has NO department
- Customers 18, 19, 20 have NO orders
- Products 19, 20 were NEVER ordered
- Category 11 (Books) has NO products
- Some employees share the same salary (for RANK / DENSE_RANK ties)
You can run this file again any time to reset the core data.
SET ANSI_NULLS ON;
SET QUOTED_IDENTIFIER ON;
GO
IF DB_ID('SqlLearningDb') IS NULL
CREATE DATABASE SqlLearningDb;
GO
USE SqlLearningDb;
GO
-- Topic scripts create tables with foreign keys to the core tables (e.g. Payments -> Orders).
-- Remove those foreign keys first so the core tables can be dropped and re-created.
-- (Re-run a topic script to get its tables back with their keys.)
DECLARE @dropFK NVARCHAR(MAX) = N'';
SELECT @dropFK += N'ALTER TABLE ' + QUOTENAME(SCHEMA_NAME(fk.schema_id)) + N'.' + QUOTENAME(OBJECT_NAME(fk.parent_object_id))
+ N' DROP CONSTRAINT ' + QUOTENAME(fk.name) + N';' + CHAR(10)
FROM sys.foreign_keys fk
WHERE OBJECT_NAME(fk.referenced_object_id) IN ('Departments', 'Employees', 'Customers', 'Categories', 'Products', 'Orders', 'OrderItems', 'Sales')
AND OBJECT_NAME(fk.parent_object_id) NOT IN ('Departments', 'Employees', 'Customers', 'Categories', 'Products', 'Orders', 'OrderItems', 'Sales');
EXEC sys.sp_executesql @dropFK;
-- Drop child tables first, then parent tables (foreign key order)
DROP TABLE IF EXISTS dbo.OrderItems;
DROP TABLE IF EXISTS dbo.Sales;
DROP TABLE IF EXISTS dbo.Orders;
DROP TABLE IF EXISTS dbo.Products;
DROP TABLE IF EXISTS dbo.Categories;
DROP TABLE IF EXISTS dbo.Customers;
DROP TABLE IF EXISTS dbo.Employees;
DROP TABLE IF EXISTS dbo.Departments;
GO
1. Departments
CREATE TABLE dbo.Departments
(
DepartmentID INT IDENTITY(1,1) PRIMARY KEY,
DepartmentName VARCHAR(50) NOT NULL UNIQUE,
Location VARCHAR(50) NOT NULL,
Budget DECIMAL(12,2) NOT NULL
);
SET IDENTITY_INSERT dbo.Departments ON;
INSERT INTO dbo.Departments (DepartmentID, DepartmentName, Location, Budget) VALUES
(1, 'Executive', 'Hyderabad', 5000000.00),
(2, 'Sales', 'Mumbai', 3000000.00),
(3, 'Marketing', 'Mumbai', 1500000.00),
(4, 'IT', 'Bengaluru', 4000000.00),
(5, 'HR', 'Hyderabad', 800000.00),
(6, 'Finance', 'Hyderabad', 1200000.00),
(7, 'Operations', 'Chennai', 2000000.00),
(8, 'Research', 'Pune', 1000000.00); -- no employees
SET IDENTITY_INSERT dbo.Departments OFF;
GO
2. Employees (ManagerID points to another EmployeeID = hierarchy)
CREATE TABLE dbo.Employees
(
EmployeeID INT IDENTITY(1,1) PRIMARY KEY,
FirstName VARCHAR(50) NOT NULL,
LastName VARCHAR(50) NOT NULL,
Email VARCHAR(100) NOT NULL UNIQUE,
Gender CHAR(1) NOT NULL CHECK (Gender IN ('M', 'F')),
DepartmentID INT NULL REFERENCES dbo.Departments(DepartmentID),
ManagerID INT NULL REFERENCES dbo.Employees(EmployeeID),
JobTitle VARCHAR(50) NOT NULL,
Salary DECIMAL(10,2) NOT NULL,
HireDate DATE NOT NULL,
City VARCHAR(50) NOT NULL,
IsActive BIT NOT NULL DEFAULT 1
);
SET IDENTITY_INSERT dbo.Employees ON;
INSERT INTO dbo.Employees
(EmployeeID, FirstName, LastName, Email, Gender, DepartmentID, ManagerID, JobTitle, Salary, HireDate, City, IsActive)
VALUES
(1, 'Rajesh', 'Kumar', 'rajesh.kumar@store.com', 'M', 1, NULL, 'CEO', 250000, '2015-01-10', 'Hyderabad', 1),
(2, 'Anita', 'Sharma', 'anita.sharma@store.com', 'F', 2, 1, 'VP Sales', 180000, '2016-03-15', 'Mumbai', 1),
(3, 'Vikram', 'Reddy', 'vikram.reddy@store.com', 'M', 4, 1, 'CTO', 190000, '2016-06-01', 'Bengaluru', 1),
(4, 'Meena', 'Iyer', 'meena.iyer@store.com', 'F', 5, 1, 'HR Manager', 120000, '2017-02-20', 'Hyderabad', 1),
(5, 'Suresh', 'Patel', 'suresh.patel@store.com', 'M', 6, 1, 'Finance Manager', 130000, '2017-08-11', 'Hyderabad', 1),
(6, 'Kavya', 'Nair', 'kavya.nair@store.com', 'F', 3, 2, 'Marketing Manager', 110000, '2018-01-05', 'Mumbai', 1),
(7, 'Arjun', 'Mehta', 'arjun.mehta@store.com', 'M', 2, 2, 'Sales Manager', 100000, '2018-04-17', 'Mumbai', 1),
(8, 'Pooja', 'Singh', 'pooja.singh@store.com', 'F', 2, 7, 'Sales Executive', 55000, '2019-07-01', 'Delhi', 1),
(9, 'Rahul', 'Verma', 'rahul.verma@store.com', 'M', 2, 7, 'Sales Executive', 52000, '2020-01-13', 'Pune', 1),
(10, 'Sneha', 'Gupta', 'sneha.gupta@store.com', 'F', 2, 7, 'Sales Executive', 58000, '2020-09-21', 'Chennai', 1),
(11, 'Kiran', 'Rao', 'kiran.rao@store.com', 'M', 4, 3, 'Senior Developer', 95000, '2018-11-30', 'Bengaluru', 1),
(12, 'Divya', 'Menon', 'divya.menon@store.com', 'F', 4, 11, 'Developer', 70000, '2021-02-08', 'Bengaluru', 1),
(13, 'Amit', 'Joshi', 'amit.joshi@store.com', 'M', 4, 11, 'Developer', 68000, '2021-06-14', 'Bengaluru', 1),
(14, 'Neha', 'Kapoor', 'neha.kapoor@store.com', 'F', 4, 3, 'Data Analyst', 75000, '2022-03-01', 'Hyderabad', 1),
(15, 'Sanjay', 'Das', 'sanjay.das@store.com', 'M', 4, 3, 'DBA', 90000, '2019-10-10', 'Kolkata', 1),
(16, 'Priya', 'Pillai', 'priya.pillai@store.com', 'F', 5, 4, 'HR Executive', 45000, '2022-07-18', 'Hyderabad', 1),
(17, 'Manoj', 'Tiwari', 'manoj.tiwari@store.com', 'M', 6, 5, 'Accountant', 60000, '2020-05-25', 'Hyderabad', 1),
(18, 'Lakshmi', 'Rao', 'lakshmi.rao@store.com', 'F', 6, 5, 'Accountant', 62000, '2021-12-01', 'Hyderabad', 1),
(19, 'Rohit', 'Bansal', 'rohit.bansal@store.com', 'M', 3, 6, 'Marketing Executive', 50000, '2022-09-12', 'Mumbai', 1),
(20, 'Swati', 'Jain', 'swati.jain@store.com', 'F', 3, 6, 'Content Writer', 42000, '2023-01-09', 'Jaipur', 1),
(21, 'Deepak', 'Chauhan', 'deepak.chauhan@store.com', 'M', 7, 1, 'Operations Manager', 105000, '2017-11-03', 'Chennai', 1),
(22, 'Farhan', 'Ali', 'farhan.ali@store.com', 'M', 7, 21, 'Logistics Executive', 40000, '2023-04-24', 'Chennai', 1),
(23, 'Ritu', 'Saxena', 'ritu.saxena@store.com', 'F', 2, 7, 'Sales Executive', 55000, '2021-03-29', 'Lucknow', 1),
(24, 'Naveen', 'Kumar', 'naveen.kumar@store.com', 'M', NULL, 11, 'Intern', 20000, '2025-01-06', 'Bengaluru', 1),
(25, 'Geeta', 'Bhat', 'geeta.bhat@store.com', 'F', 4, 11, 'Developer', 70000, '2020-08-17', 'Bengaluru', 0);
SET IDENTITY_INSERT dbo.Employees OFF;
GO
3. Customers
CREATE TABLE dbo.Customers
(
CustomerID INT IDENTITY(1,1) PRIMARY KEY,
CustomerName VARCHAR(100) NOT NULL,
Email VARCHAR(100) NULL,
Phone VARCHAR(20) NULL,
City VARCHAR(50) NOT NULL,
State VARCHAR(50) NOT NULL,
Segment VARCHAR(20) NOT NULL CHECK (Segment IN ('Retail', 'Corporate', 'SMB')),
SignupDate DATE NOT NULL
);
SET IDENTITY_INSERT dbo.Customers ON;
INSERT INTO dbo.Customers (CustomerID, CustomerName, Email, Phone, City, State, Segment, SignupDate) VALUES
(1, 'Ravi Traders', 'ravi@traders.in', '9876500001', 'Hyderabad', 'Telangana', 'SMB', '2023-05-10'),
(2, 'Infosoft Solutions', 'it@infosoft.in', '9876500002', 'Bengaluru', 'Karnataka', 'Corporate', '2023-06-01'),
(3, 'Lakshmi Stores', 'lakshmi@stores.in', '9876500003', 'Chennai', 'Tamil Nadu', 'Retail', '2023-07-15'),
(4, 'Mumbai Mart', 'contact@mumbaimart.in', '9876500004', 'Mumbai', 'Maharashtra', 'Retail', '2023-08-20'),
(5, 'Pune Tech Park', 'admin@punetech.in', '9876500005', 'Pune', 'Maharashtra', 'Corporate', '2023-09-05'),
(6, 'Capital Electronics', 'sales@capital.in', '9876500006', 'Delhi', 'Delhi', 'SMB', '2023-10-12'),
(7, 'Bengal Book House', NULL, '9876500007', 'Kolkata', 'West Bengal', 'Retail', '2023-11-01'),
(8, 'Deccan Systems', 'buy@deccan.in', '9876500008', 'Hyderabad', 'Telangana', 'Corporate', '2023-12-18'),
(9, 'Gujarat Office Supply', 'office@gos.in', NULL, 'Ahmedabad', 'Gujarat', 'SMB', '2024-01-07'),
(10, 'Pink City Furnishers', 'pink@furnish.in', '9876500010', 'Jaipur', 'Rajasthan', 'SMB', '2024-02-14'),
(11, 'Kerala Kart', 'hello@keralakart.in', '9876500011', 'Kochi', 'Kerala', 'Retail', '2024-03-03'),
(12, 'Awadh Enterprises', 'info@awadh.in', '9876500012', 'Lucknow', 'Uttar Pradesh', 'SMB', '2024-03-28'),
(13, 'Silicon Valley Pvt Ltd','procure@svpl.in', '9876500013', 'Bengaluru', 'Karnataka', 'Corporate', '2024-04-19'),
(14, 'Gateway Retail', 'gw@retail.in', '9876500014', 'Mumbai', 'Maharashtra', 'Retail', '2024-05-30'),
(15, 'Marina Digital', 'md@marina.in', '9876500015', 'Chennai', 'Tamil Nadu', 'Corporate', '2024-06-22'),
(16, 'Northern Distributors', 'nd@north.in', '9876500016', 'Delhi', 'Delhi', 'SMB', '2024-07-09'),
(17, 'Shivaji Stationers', 'shivaji@stat.in', '9876500017', 'Pune', 'Maharashtra', 'Retail', '2024-08-15'),
(18, 'Nizam Bakers', 'nizam@bakers.in', '9876500018', 'Hyderabad', 'Telangana', 'Retail', '2025-01-11'), -- no orders
(19, 'Coastal Exports', NULL, NULL, 'Visakhapatnam','Andhra Pradesh','SMB', '2025-02-02'), -- no orders
(20, 'Himalaya Ventures', 'hv@himalaya.in', '9876500020', 'Dehradun', 'Uttarakhand', 'Corporate', '2025-03-17'); -- no orders
SET IDENTITY_INSERT dbo.Customers OFF;
GO
4. Categories (ParentCategoryID = hierarchy, used in Recursive CTE)
CREATE TABLE dbo.Categories
(
CategoryID INT IDENTITY(1,1) PRIMARY KEY,
CategoryName VARCHAR(50) NOT NULL,
ParentCategoryID INT NULL REFERENCES dbo.Categories(CategoryID)
);
SET IDENTITY_INSERT dbo.Categories ON;
INSERT INTO dbo.Categories (CategoryID, CategoryName, ParentCategoryID) VALUES
(1, 'Electronics', NULL),
(2, 'Computers', 1),
(3, 'Laptops', 2),
(4, 'Desktops', 2),
(5, 'Mobiles', 1),
(6, 'Accessories', 1),
(7, 'Furniture', NULL),
(8, 'Office Chairs', 7),
(9, 'Desks', 7),
(10, 'Stationery', NULL),
(11, 'Books', NULL); -- no products
SET IDENTITY_INSERT dbo.Categories OFF;
GO
5. Products
CREATE TABLE dbo.Products
(
ProductID INT IDENTITY(1,1) PRIMARY KEY,
ProductName VARCHAR(100) NOT NULL,
CategoryID INT NOT NULL REFERENCES dbo.Categories(CategoryID),
UnitPrice DECIMAL(10,2) NOT NULL,
CostPrice DECIMAL(10,2) NOT NULL,
StockQty INT NOT NULL,
Discontinued BIT NOT NULL DEFAULT 0
);
SET IDENTITY_INSERT dbo.Products ON;
INSERT INTO dbo.Products (ProductID, ProductName, CategoryID, UnitPrice, CostPrice, StockQty, Discontinued) VALUES
(1, 'Dell Inspiron 15', 3, 65000, 52000, 25, 0),
(2, 'HP Pavilion 14', 3, 85000, 70000, 15, 0),
(3, 'MacBook Air M3', 3, 120000, 98000, 10, 0),
(4, 'Lenovo ThinkCentre', 4, 55000, 44000, 8, 0),
(5, 'Acer Aspire Desktop', 4, 45000, 36000, 12, 0),
(6, 'Samsung Galaxy A55', 5, 25000, 19000, 40, 0),
(7, 'iPhone 15', 5, 70000, 58000, 20, 0),
(8, 'Redmi Note 13', 5, 15000, 11000, 60, 0),
(9, 'Wireless Mouse', 6, 1200, 700, 200, 0),
(10, 'Mechanical Keyboard', 6, 2500, 1600, 120, 0),
(11, '27 inch Monitor', 6, 18000, 14000, 30, 0),
(12, 'USB-C Hub', 6, 3500, 2200, 80, 0),
(13, 'Ergonomic Office Chair', 8, 12000, 8000, 35, 0),
(14, 'Basic Office Chair', 8, 8500, 6000, 50, 0),
(15, 'Standing Desk', 9, 22000, 16000, 18, 0),
(16, 'A4 Notebook (Pack of 5)', 10, 150, 90, 500, 0),
(17, 'Ball Pen (Pack of 10)', 10, 60, 35, 800, 0),
(18, 'Desk Organizer', 10, 450, 280, 150, 0),
(19, 'Old Model Tablet', 5, 18000, 15000, 0, 1), -- never ordered, discontinued
(20, 'Laser Printer', 6, 16000, 12500, 5, 0); -- never ordered
SET IDENTITY_INSERT dbo.Products OFF;
GO
6. Orders (Jan 2024 - Jun 2025)
CREATE TABLE dbo.Orders
(
OrderID INT IDENTITY(1,1) PRIMARY KEY,
CustomerID INT NOT NULL REFERENCES dbo.Customers(CustomerID),
EmployeeID INT NOT NULL REFERENCES dbo.Employees(EmployeeID), -- sales person
OrderDate DATE NOT NULL,
ShipDate DATE NULL,
Status VARCHAR(20) NOT NULL CHECK (Status IN ('Pending', 'Shipped', 'Delivered', 'Cancelled')),
ShipCity VARCHAR(50) NOT NULL
);
7. OrderItems (LineTotal is a computed column)
CREATE TABLE dbo.OrderItems
(
OrderItemID INT IDENTITY(1,1) PRIMARY KEY,
OrderID INT NOT NULL REFERENCES dbo.Orders(OrderID),
ProductID INT NOT NULL REFERENCES dbo.Products(ProductID),
Quantity INT NOT NULL CHECK (Quantity > 0),
UnitPrice DECIMAL(10,2) NOT NULL,
Discount DECIMAL(4,2) NOT NULL DEFAULT 0, -- 0.10 = 10%
LineTotal AS (CAST(Quantity * UnitPrice * (1 - Discount) AS DECIMAL(12,2))) PERSISTED
);
8. Sales (flat daily sales, Jan 2025 - Jun 2025)
CREATE TABLE dbo.Sales
(
SaleID INT IDENTITY(1,1) PRIMARY KEY,
SaleDate DATE NOT NULL,
Region VARCHAR(10) NOT NULL,
EmployeeID INT NOT NULL REFERENCES dbo.Employees(EmployeeID),
ProductID INT NOT NULL REFERENCES dbo.Products(ProductID),
Quantity INT NOT NULL,
UnitPrice DECIMAL(10,2) NOT NULL,
TotalAmount AS (CAST(Quantity * UnitPrice AS DECIMAL(12,2))) PERSISTED
);
GO
Orders Data
SET IDENTITY_INSERT dbo.Orders ON;
INSERT INTO dbo.Orders (OrderID, CustomerID, EmployeeID, OrderDate, ShipDate, Status, ShipCity) VALUES
(1, 1, 9, '2024-01-09', '2024-01-11', 'Delivered', 'Hyderabad'),
(2, 8, 23, '2024-01-17', NULL, 'Cancelled', 'Hyderabad'),
(3, 8, 10, '2024-01-26', NULL, 'Cancelled', 'Hyderabad'),
(4, 13, 7, '2024-01-29', '2024-02-01', 'Delivered', 'Bengaluru'),
(5, 3, 7, '2024-02-06', '2024-02-09', 'Delivered', 'Chennai'),
(6, 15, 9, '2024-02-14', '2024-02-17', 'Delivered', 'Chennai'),
(7, 4, 23, '2024-02-20', '2024-02-26', 'Delivered', 'Mumbai'),
(8, 7, 10, '2024-02-27', '2024-03-04', 'Delivered', 'Kolkata'),
(9, 3, 7, '2024-03-06', '2024-03-08', 'Delivered', 'Chennai'),
(10, 1, 7, '2024-03-12', '2024-03-18', 'Delivered', 'Hyderabad'),
(11, 17, 7, '2024-03-17', '2024-03-23', 'Delivered', 'Pune'),
(12, 16, 7, '2024-03-25', '2024-03-28', 'Delivered', 'Delhi'),
(13, 1, 8, '2024-04-02', '2024-04-07', 'Delivered', 'Hyderabad'),
(14, 2, 23, '2024-04-05', '2024-04-10', 'Delivered', 'Bengaluru'),
(15, 3, 23, '2024-04-14', '2024-04-17', 'Delivered', 'Chennai'),
(16, 15, 7, '2024-04-22', '2024-04-23', 'Delivered', 'Chennai'),
(17, 3, 10, '2024-04-26', '2024-04-27', 'Delivered', 'Chennai'),
(18, 6, 10, '2024-05-03', '2024-05-07', 'Delivered', 'Delhi'),
(19, 15, 9, '2024-05-11', '2024-05-17', 'Delivered', 'Chennai'),
(20, 2, 23, '2024-05-17', '2024-05-19', 'Delivered', 'Bengaluru'),
(21, 2, 8, '2024-05-22', NULL, 'Cancelled', 'Bengaluru'),
(22, 9, 8, '2024-05-31', '2024-06-02', 'Delivered', 'Ahmedabad'),
(23, 3, 23, '2024-06-05', '2024-06-10', 'Delivered', 'Chennai'),
(24, 3, 23, '2024-06-13', '2024-06-19', 'Delivered', 'Chennai'),
(25, 11, 8, '2024-06-19', '2024-06-24', 'Delivered', 'Kochi'),
(26, 1, 10, '2024-06-28', '2024-06-29', 'Delivered', 'Hyderabad'),
(27, 12, 23, '2024-07-01', '2024-07-03', 'Delivered', 'Lucknow'),
(28, 8, 8, '2024-07-09', '2024-07-13', 'Delivered', 'Hyderabad'),
(29, 9, 8, '2024-07-16', '2024-07-20', 'Delivered', 'Ahmedabad'),
(30, 12, 9, '2024-07-25', '2024-07-27', 'Delivered', 'Lucknow'),
(31, 3, 9, '2024-07-30', '2024-08-05', 'Delivered', 'Chennai'),
(32, 14, 23, '2024-08-06', '2024-08-07', 'Delivered', 'Mumbai'),
(33, 5, 7, '2024-08-13', '2024-08-18', 'Delivered', 'Pune'),
(34, 3, 23, '2024-08-18', '2024-08-22', 'Delivered', 'Chennai'),
(35, 2, 23, '2024-08-27', '2024-08-31', 'Delivered', 'Bengaluru'),
(36, 7, 8, '2024-09-01', '2024-09-02', 'Delivered', 'Kolkata'),
(37, 13, 8, '2024-09-09', '2024-09-15', 'Delivered', 'Bengaluru'),
(38, 17, 10, '2024-09-14', '2024-09-19', 'Delivered', 'Pune'),
(39, 1, 10, '2024-09-23', '2024-09-29', 'Delivered', 'Hyderabad'),
(40, 9, 9, '2024-09-28', '2024-10-03', 'Delivered', 'Ahmedabad');
INSERT INTO dbo.Orders (OrderID, CustomerID, EmployeeID, OrderDate, ShipDate, Status, ShipCity) VALUES
(41, 5, 8, '2024-10-06', '2024-10-10', 'Delivered', 'Pune'),
(42, 12, 9, '2024-10-10', '2024-10-14', 'Delivered', 'Lucknow'),
(43, 11, 10, '2024-10-20', '2024-10-24', 'Delivered', 'Kochi'),
(44, 5, 10, '2024-10-26', '2024-10-27', 'Delivered', 'Pune'),
(45, 3, 10, '2024-11-01', '2024-11-07', 'Delivered', 'Chennai'),
(46, 1, 8, '2024-11-06', '2024-11-07', 'Delivered', 'Hyderabad'),
(47, 12, 8, '2024-11-14', NULL, 'Cancelled', 'Lucknow'),
(48, 10, 23, '2024-11-19', '2024-11-23', 'Delivered', 'Jaipur'),
(49, 12, 23, '2024-11-26', '2024-12-02', 'Delivered', 'Lucknow'),
(50, 5, 10, '2024-12-06', '2024-12-12', 'Delivered', 'Pune'),
(51, 15, 8, '2024-12-11', '2024-12-16', 'Delivered', 'Chennai'),
(52, 1, 7, '2024-12-18', '2024-12-20', 'Delivered', 'Hyderabad'),
(53, 16, 10, '2024-12-24', '2024-12-25', 'Delivered', 'Delhi'),
(54, 10, 23, '2024-12-30', '2025-01-03', 'Delivered', 'Jaipur'),
(55, 11, 7, '2025-01-06', '2025-01-12', 'Delivered', 'Kochi'),
(56, 10, 8, '2025-01-13', '2025-01-15', 'Delivered', 'Jaipur'),
(57, 2, 9, '2025-01-18', '2025-01-22', 'Delivered', 'Bengaluru'),
(58, 2, 9, '2025-01-26', '2025-01-28', 'Delivered', 'Bengaluru'),
(59, 17, 10, '2025-02-02', '2025-02-06', 'Delivered', 'Pune'),
(60, 6, 23, '2025-02-09', '2025-02-11', 'Delivered', 'Delhi'),
(61, 10, 7, '2025-02-17', '2025-02-20', 'Delivered', 'Jaipur'),
(62, 4, 8, '2025-02-22', '2025-02-24', 'Delivered', 'Mumbai'),
(63, 15, 7, '2025-03-02', '2025-03-08', 'Delivered', 'Chennai'),
(64, 1, 7, '2025-03-08', '2025-03-14', 'Delivered', 'Hyderabad'),
(65, 17, 10, '2025-03-16', '2025-03-18', 'Delivered', 'Pune'),
(66, 5, 10, '2025-03-22', '2025-03-23', 'Delivered', 'Pune'),
(67, 3, 10, '2025-03-28', '2025-03-29', 'Delivered', 'Chennai'),
(68, 4, 23, '2025-04-02', '2025-04-08', 'Delivered', 'Mumbai'),
(69, 4, 8, '2025-04-12', '2025-04-18', 'Shipped', 'Mumbai'),
(70, 3, 23, '2025-04-17', '2025-04-18', 'Delivered', 'Chennai'),
(71, 1, 10, '2025-04-25', '2025-04-28', 'Delivered', 'Hyderabad'),
(72, 13, 8, '2025-05-02', '2025-05-03', 'Shipped', 'Bengaluru'),
(73, 1, 8, '2025-05-09', '2025-05-15', 'Delivered', 'Hyderabad'),
(74, 5, 23, '2025-05-14', '2025-05-17', 'Delivered', 'Pune'),
(75, 1, 7, '2025-05-21', '2025-05-22', 'Delivered', 'Hyderabad'),
(76, 3, 23, '2025-05-27', '2025-06-01', 'Delivered', 'Chennai'),
(77, 5, 7, '2025-06-03', '2025-06-06', 'Shipped', 'Pune'),
(78, 15, 9, '2025-06-10', '2025-06-14', 'Delivered', 'Chennai'),
(79, 3, 10, '2025-06-15', '2025-06-17', 'Delivered', 'Chennai'),
(80, 5, 7, '2025-06-24', '2025-06-27', 'Delivered', 'Pune');
SET IDENTITY_INSERT dbo.Orders OFF;
-- Preview: first 10 orders
SELECT TOP (10) * FROM dbo.Orders ORDER BY OrderID;
GO
Output
| OrderID | CustomerID | EmployeeID | OrderDate | ShipDate | Status | ShipCity |
|---|---|---|---|---|---|---|
| 1 | 1 | 9 | 2024-01-09 | 2024-01-11 | Delivered | Hyderabad |
| 2 | 8 | 23 | 2024-01-17 | NULL | Cancelled | Hyderabad |
| 3 | 8 | 10 | 2024-01-26 | NULL | Cancelled | Hyderabad |
| 4 | 13 | 7 | 2024-01-29 | 2024-02-01 | Delivered | Bengaluru |
| 5 | 3 | 7 | 2024-02-06 | 2024-02-09 | Delivered | Chennai |
| 6 | 15 | 9 | 2024-02-14 | 2024-02-17 | Delivered | Chennai |
| 7 | 4 | 23 | 2024-02-20 | 2024-02-26 | Delivered | Mumbai |
| 8 | 7 | 10 | 2024-02-27 | 2024-03-04 | Delivered | Kolkata |
| 9 | 3 | 7 | 2024-03-06 | 2024-03-08 | Delivered | Chennai |
| 10 | 1 | 7 | 2024-03-12 | 2024-03-18 | Delivered | Hyderabad |
OrderItems Data
SET IDENTITY_INSERT dbo.OrderItems ON;
INSERT INTO dbo.OrderItems (OrderItemID, OrderID, ProductID, Quantity, UnitPrice, Discount) VALUES
(1, 1, 4, 3, 55000.00, 0.00),
(2, 1, 3, 1, 120000.00, 0.00),
(3, 2, 18, 2, 450.00, 0.10),
(4, 3, 1, 2, 65000.00, 0.00),
(5, 3, 6, 1, 25000.00, 0.00),
(6, 3, 14, 2, 8500.00, 0.00),
(7, 4, 2, 3, 85000.00, 0.00),
(8, 4, 15, 2, 22000.00, 0.10),
(9, 4, 4, 2, 55000.00, 0.10),
(10, 5, 8, 1, 15000.00, 0.05),
(11, 6, 7, 1, 70000.00, 0.10),
(12, 6, 9, 2, 1200.00, 0.00),
(13, 6, 3, 3, 120000.00, 0.05),
(14, 7, 2, 2, 85000.00, 0.05),
(15, 7, 8, 2, 15000.00, 0.00),
(16, 7, 18, 2, 450.00, 0.10),
(17, 8, 5, 2, 45000.00, 0.10),
(18, 8, 9, 5, 1200.00, 0.10),
(19, 8, 18, 5, 450.00, 0.00),
(20, 8, 4, 1, 55000.00, 0.00),
(21, 9, 14, 3, 8500.00, 0.05),
(22, 9, 3, 3, 120000.00, 0.10),
(23, 10, 11, 3, 18000.00, 0.00),
(24, 10, 4, 3, 55000.00, 0.00),
(25, 10, 10, 2, 2500.00, 0.10),
(26, 11, 5, 1, 45000.00, 0.10),
(27, 11, 12, 1, 3500.00, 0.10),
(28, 12, 8, 1, 15000.00, 0.00),
(29, 12, 2, 3, 85000.00, 0.00),
(30, 12, 18, 1, 450.00, 0.00),
(31, 13, 7, 2, 70000.00, 0.05),
(32, 13, 18, 10, 450.00, 0.00),
(33, 13, 10, 2, 2500.00, 0.00),
(34, 13, 17, 1, 60.00, 0.00),
(35, 14, 1, 1, 65000.00, 0.00),
(36, 14, 3, 1, 120000.00, 0.00),
(37, 15, 7, 3, 70000.00, 0.05),
(38, 15, 5, 1, 45000.00, 0.00),
(39, 15, 16, 1, 150.00, 0.05),
(40, 15, 4, 2, 55000.00, 0.05);
INSERT INTO dbo.OrderItems (OrderItemID, OrderID, ProductID, Quantity, UnitPrice, Discount) VALUES
(41, 16, 11, 1, 18000.00, 0.10),
(42, 16, 4, 3, 55000.00, 0.00),
(43, 16, 8, 3, 15000.00, 0.00),
(44, 16, 17, 2, 60.00, 0.05),
(45, 17, 18, 1, 450.00, 0.00),
(46, 18, 13, 1, 12000.00, 0.05),
(47, 18, 2, 1, 85000.00, 0.05),
(48, 19, 5, 1, 45000.00, 0.10),
(49, 19, 7, 1, 70000.00, 0.00),
(50, 19, 10, 1, 2500.00, 0.00),
(51, 19, 4, 3, 55000.00, 0.10),
(52, 20, 3, 1, 120000.00, 0.05),
(53, 21, 3, 3, 120000.00, 0.10),
(54, 22, 13, 3, 12000.00, 0.00),
(55, 22, 5, 1, 45000.00, 0.00),
(56, 22, 10, 10, 2500.00, 0.10),
(57, 23, 5, 1, 45000.00, 0.00),
(58, 23, 12, 2, 3500.00, 0.00),
(59, 23, 3, 3, 120000.00, 0.10),
(60, 24, 4, 1, 55000.00, 0.00),
(61, 24, 5, 1, 45000.00, 0.00),
(62, 24, 9, 2, 1200.00, 0.10),
(63, 25, 9, 5, 1200.00, 0.00),
(64, 25, 2, 1, 85000.00, 0.00),
(65, 25, 3, 2, 120000.00, 0.00),
(66, 25, 11, 2, 18000.00, 0.00),
(67, 26, 3, 1, 120000.00, 0.10),
(68, 27, 5, 1, 45000.00, 0.00),
(69, 27, 2, 1, 85000.00, 0.00),
(70, 27, 10, 1, 2500.00, 0.00),
(71, 27, 6, 3, 25000.00, 0.10),
(72, 28, 6, 2, 25000.00, 0.05),
(73, 29, 16, 2, 150.00, 0.00),
(74, 30, 7, 3, 70000.00, 0.00),
(75, 31, 18, 2, 450.00, 0.00),
(76, 31, 11, 2, 18000.00, 0.00),
(77, 31, 1, 1, 65000.00, 0.10),
(78, 31, 2, 3, 85000.00, 0.00),
(79, 32, 7, 3, 70000.00, 0.00),
(80, 32, 9, 2, 1200.00, 0.00);
INSERT INTO dbo.OrderItems (OrderItemID, OrderID, ProductID, Quantity, UnitPrice, Discount) VALUES
(81, 32, 2, 3, 85000.00, 0.00),
(82, 32, 12, 3, 3500.00, 0.10),
(83, 33, 14, 2, 8500.00, 0.10),
(84, 33, 11, 1, 18000.00, 0.00),
(85, 33, 13, 3, 12000.00, 0.05),
(86, 34, 10, 2, 2500.00, 0.00),
(87, 35, 15, 1, 22000.00, 0.00),
(88, 35, 7, 2, 70000.00, 0.10),
(89, 35, 16, 3, 150.00, 0.00),
(90, 35, 13, 1, 12000.00, 0.00),
(91, 36, 16, 10, 150.00, 0.05),
(92, 36, 3, 1, 120000.00, 0.05),
(93, 37, 4, 3, 55000.00, 0.00),
(94, 38, 4, 1, 55000.00, 0.05),
(95, 38, 15, 2, 22000.00, 0.05),
(96, 39, 15, 2, 22000.00, 0.10),
(97, 39, 9, 10, 1200.00, 0.00),
(98, 39, 8, 2, 15000.00, 0.05),
(99, 39, 14, 1, 8500.00, 0.00),
(100, 40, 5, 1, 45000.00, 0.00),
(101, 41, 11, 1, 18000.00, 0.05),
(102, 41, 15, 3, 22000.00, 0.10),
(103, 41, 14, 1, 8500.00, 0.10),
(104, 41, 1, 3, 65000.00, 0.05),
(105, 42, 16, 2, 150.00, 0.05),
(106, 42, 8, 3, 15000.00, 0.00),
(107, 43, 18, 5, 450.00, 0.10),
(108, 43, 1, 1, 65000.00, 0.00),
(109, 44, 13, 3, 12000.00, 0.00),
(110, 44, 11, 2, 18000.00, 0.05),
(111, 44, 7, 2, 70000.00, 0.05),
(112, 45, 12, 2, 3500.00, 0.00),
(113, 46, 8, 3, 15000.00, 0.00),
(114, 46, 5, 1, 45000.00, 0.05),
(115, 47, 6, 2, 25000.00, 0.00),
(116, 48, 3, 1, 120000.00, 0.00),
(117, 48, 8, 1, 15000.00, 0.10),
(118, 49, 3, 1, 120000.00, 0.05),
(119, 49, 17, 10, 60.00, 0.00),
(120, 49, 11, 3, 18000.00, 0.00);
INSERT INTO dbo.OrderItems (OrderItemID, OrderID, ProductID, Quantity, UnitPrice, Discount) VALUES
(121, 50, 18, 5, 450.00, 0.10),
(122, 50, 16, 2, 150.00, 0.00),
(123, 50, 15, 1, 22000.00, 0.00),
(124, 51, 11, 2, 18000.00, 0.00),
(125, 51, 1, 3, 65000.00, 0.00),
(126, 51, 16, 3, 150.00, 0.00),
(127, 51, 14, 2, 8500.00, 0.00),
(128, 52, 8, 3, 15000.00, 0.05),
(129, 53, 10, 2, 2500.00, 0.05),
(130, 54, 14, 3, 8500.00, 0.00),
(131, 54, 11, 2, 18000.00, 0.00),
(132, 54, 12, 2, 3500.00, 0.00),
(133, 55, 7, 3, 70000.00, 0.00),
(134, 55, 18, 2, 450.00, 0.00),
(135, 56, 1, 1, 65000.00, 0.00),
(136, 56, 5, 2, 45000.00, 0.00),
(137, 56, 9, 10, 1200.00, 0.00),
(138, 57, 11, 3, 18000.00, 0.00),
(139, 57, 6, 1, 25000.00, 0.05),
(140, 57, 2, 3, 85000.00, 0.00),
(141, 57, 5, 1, 45000.00, 0.00),
(142, 58, 18, 5, 450.00, 0.10),
(143, 59, 14, 1, 8500.00, 0.00),
(144, 59, 10, 2, 2500.00, 0.00),
(145, 59, 2, 1, 85000.00, 0.00),
(146, 60, 14, 3, 8500.00, 0.10),
(147, 61, 15, 2, 22000.00, 0.10),
(148, 61, 3, 1, 120000.00, 0.05),
(149, 61, 8, 1, 15000.00, 0.10),
(150, 62, 2, 1, 85000.00, 0.00),
(151, 63, 13, 3, 12000.00, 0.00),
(152, 63, 9, 1, 1200.00, 0.05),
(153, 63, 16, 3, 150.00, 0.10),
(154, 64, 9, 1, 1200.00, 0.00),
(155, 65, 16, 5, 150.00, 0.00),
(156, 65, 3, 2, 120000.00, 0.00),
(157, 65, 18, 1, 450.00, 0.00),
(158, 65, 6, 3, 25000.00, 0.05),
(159, 66, 3, 1, 120000.00, 0.05),
(160, 66, 11, 1, 18000.00, 0.10);
INSERT INTO dbo.OrderItems (OrderItemID, OrderID, ProductID, Quantity, UnitPrice, Discount) VALUES
(161, 66, 9, 10, 1200.00, 0.05),
(162, 66, 6, 1, 25000.00, 0.00),
(163, 67, 9, 2, 1200.00, 0.05),
(164, 67, 5, 3, 45000.00, 0.00),
(165, 68, 10, 5, 2500.00, 0.00),
(166, 68, 1, 1, 65000.00, 0.00),
(167, 69, 17, 10, 60.00, 0.05),
(168, 69, 9, 2, 1200.00, 0.05),
(169, 69, 14, 1, 8500.00, 0.05),
(170, 70, 14, 1, 8500.00, 0.00),
(171, 70, 11, 2, 18000.00, 0.10),
(172, 70, 9, 10, 1200.00, 0.00),
(173, 71, 15, 1, 22000.00, 0.10),
(174, 71, 11, 3, 18000.00, 0.00),
(175, 71, 7, 3, 70000.00, 0.00),
(176, 71, 12, 3, 3500.00, 0.05),
(177, 72, 17, 1, 60.00, 0.05),
(178, 72, 11, 1, 18000.00, 0.10),
(179, 73, 3, 2, 120000.00, 0.00),
(180, 73, 16, 5, 150.00, 0.00),
(181, 74, 18, 2, 450.00, 0.00),
(182, 74, 2, 1, 85000.00, 0.05),
(183, 74, 3, 1, 120000.00, 0.00),
(184, 74, 4, 3, 55000.00, 0.00),
(185, 75, 12, 1, 3500.00, 0.00),
(186, 75, 18, 5, 450.00, 0.10),
(187, 75, 14, 1, 8500.00, 0.00),
(188, 76, 16, 2, 150.00, 0.05),
(189, 76, 5, 2, 45000.00, 0.05),
(190, 77, 3, 2, 120000.00, 0.10),
(191, 77, 15, 2, 22000.00, 0.05),
(192, 78, 4, 2, 55000.00, 0.10),
(193, 78, 8, 2, 15000.00, 0.00),
(194, 78, 13, 1, 12000.00, 0.05),
(195, 78, 10, 2, 2500.00, 0.00),
(196, 79, 8, 1, 15000.00, 0.00),
(197, 79, 7, 1, 70000.00, 0.00),
(198, 79, 9, 10, 1200.00, 0.00),
(199, 80, 6, 2, 25000.00, 0.10),
(200, 80, 7, 2, 70000.00, 0.00);
INSERT INTO dbo.OrderItems (OrderItemID, OrderID, ProductID, Quantity, UnitPrice, Discount) VALUES
(201, 80, 5, 2, 45000.00, 0.05),
(202, 80, 13, 2, 12000.00, 0.00);
SET IDENTITY_INSERT dbo.OrderItems OFF;
-- Preview: first 10 order items
SELECT TOP (10) * FROM dbo.OrderItems ORDER BY OrderItemID;
GO
Output
| OrderItemID | OrderID | ProductID | Quantity | UnitPrice | Discount | LineTotal |
|---|---|---|---|---|---|---|
| 1 | 1 | 4 | 3 | 55000.00 | 0.00 | 165000.00 |
| 2 | 1 | 3 | 1 | 120000.00 | 0.00 | 120000.00 |
| 3 | 2 | 18 | 2 | 450.00 | 0.10 | 810.00 |
| 4 | 3 | 1 | 2 | 65000.00 | 0.00 | 130000.00 |
| 5 | 3 | 6 | 1 | 25000.00 | 0.00 | 25000.00 |
| 6 | 3 | 14 | 2 | 8500.00 | 0.00 | 17000.00 |
| 7 | 4 | 2 | 3 | 85000.00 | 0.00 | 255000.00 |
| 8 | 4 | 15 | 2 | 22000.00 | 0.10 | 39600.00 |
| 9 | 4 | 4 | 2 | 55000.00 | 0.10 | 99000.00 |
| 10 | 5 | 8 | 1 | 15000.00 | 0.05 | 14250.00 |
Sales Data
SET IDENTITY_INSERT dbo.Sales ON;
INSERT INTO dbo.Sales (SaleID, SaleDate, Region, EmployeeID, ProductID, Quantity, UnitPrice) VALUES
(1, '2025-01-02', 'South', 10, 3, 2, 120000.00),
(2, '2025-01-02', 'North', 10, 18, 12, 450.00),
(3, '2025-01-04', 'West', 9, 18, 4, 450.00),
(4, '2025-01-05', 'North', 8, 13, 3, 12000.00),
(5, '2025-01-06', 'South', 7, 1, 3, 65000.00),
(6, '2025-01-06', 'West', 7, 15, 3, 22000.00),
(7, '2025-01-07', 'East', 10, 2, 1, 85000.00),
(8, '2025-01-10', 'West', 10, 18, 5, 450.00),
(9, '2025-01-11', 'South', 10, 18, 14, 450.00),
(10, '2025-01-13', 'North', 9, 14, 3, 8500.00),
(11, '2025-01-13', 'West', 8, 7, 4, 70000.00),
(12, '2025-01-14', 'East', 7, 4, 3, 55000.00),
(13, '2025-01-15', 'North', 10, 9, 7, 1200.00),
(14, '2025-01-15', 'North', 7, 3, 2, 120000.00),
(15, '2025-01-16', 'South', 7, 8, 2, 15000.00),
(16, '2025-01-17', 'East', 8, 7, 2, 70000.00),
(17, '2025-01-19', 'East', 8, 5, 2, 45000.00),
(18, '2025-01-22', 'South', 23, 1, 3, 65000.00),
(19, '2025-01-23', 'East', 7, 1, 2, 65000.00),
(20, '2025-01-24', 'North', 10, 14, 1, 8500.00),
(21, '2025-01-25', 'North', 10, 12, 17, 3500.00),
(22, '2025-01-25', 'North', 23, 17, 8, 60.00),
(23, '2025-01-26', 'North', 10, 15, 1, 22000.00),
(24, '2025-01-27', 'West', 10, 14, 1, 8500.00),
(25, '2025-01-27', 'East', 23, 3, 1, 120000.00),
(26, '2025-01-28', 'East', 23, 3, 2, 120000.00),
(27, '2025-01-29', 'West', 23, 13, 3, 12000.00),
(28, '2025-01-30', 'South', 10, 4, 1, 55000.00),
(29, '2025-01-30', 'West', 9, 15, 2, 22000.00),
(30, '2025-01-31', 'North', 9, 13, 4, 12000.00),
(31, '2025-01-31', 'East', 9, 14, 3, 8500.00),
(32, '2025-02-01', 'North', 7, 16, 3, 150.00),
(33, '2025-02-03', 'South', 23, 4, 3, 55000.00),
(34, '2025-02-03', 'North', 10, 2, 3, 85000.00),
(35, '2025-02-04', 'East', 23, 14, 1, 8500.00),
(36, '2025-02-05', 'South', 8, 12, 4, 3500.00),
(37, '2025-02-06', 'East', 23, 8, 1, 15000.00),
(38, '2025-02-06', 'East', 23, 12, 4, 3500.00),
(39, '2025-02-07', 'East', 7, 14, 1, 8500.00),
(40, '2025-02-08', 'East', 9, 9, 10, 1200.00);
INSERT INTO dbo.Sales (SaleID, SaleDate, Region, EmployeeID, ProductID, Quantity, UnitPrice) VALUES
(41, '2025-02-10', 'North', 8, 5, 4, 45000.00),
(42, '2025-02-13', 'West', 9, 13, 4, 12000.00),
(43, '2025-02-14', 'East', 23, 12, 10, 3500.00),
(44, '2025-02-17', 'North', 9, 6, 1, 25000.00),
(45, '2025-02-18', 'West', 10, 14, 4, 8500.00),
(46, '2025-02-18', 'North', 9, 9, 7, 1200.00),
(47, '2025-02-19', 'West', 23, 4, 3, 55000.00),
(48, '2025-02-19', 'South', 10, 10, 2, 2500.00),
(49, '2025-02-22', 'South', 9, 10, 7, 2500.00),
(50, '2025-02-23', 'North', 10, 11, 1, 18000.00),
(51, '2025-02-24', 'West', 23, 6, 2, 25000.00),
(52, '2025-02-24', 'North', 10, 8, 3, 15000.00),
(53, '2025-02-26', 'North', 9, 1, 4, 65000.00),
(54, '2025-02-26', 'West', 9, 14, 4, 8500.00),
(55, '2025-02-28', 'South', 23, 1, 3, 65000.00),
(56, '2025-02-28', 'North', 10, 15, 3, 22000.00),
(57, '2025-03-02', 'North', 10, 14, 4, 8500.00),
(58, '2025-03-03', 'East', 8, 11, 2, 18000.00),
(59, '2025-03-06', 'South', 8, 12, 12, 3500.00),
(60, '2025-03-08', 'South', 23, 9, 7, 1200.00),
(61, '2025-03-09', 'West', 10, 3, 2, 120000.00),
(62, '2025-03-10', 'South', 10, 11, 3, 18000.00),
(63, '2025-03-10', 'West', 9, 3, 4, 120000.00),
(64, '2025-03-11', 'North', 9, 2, 3, 85000.00),
(65, '2025-03-12', 'North', 9, 15, 1, 22000.00),
(66, '2025-03-12', 'North', 23, 10, 3, 2500.00),
(67, '2025-03-13', 'West', 23, 15, 1, 22000.00),
(68, '2025-03-13', 'West', 23, 7, 3, 70000.00),
(69, '2025-03-14', 'North', 9, 2, 4, 85000.00),
(70, '2025-03-16', 'West', 10, 2, 2, 85000.00),
(71, '2025-03-17', 'East', 10, 12, 12, 3500.00),
(72, '2025-03-18', 'East', 7, 11, 1, 18000.00),
(73, '2025-03-18', 'West', 9, 11, 1, 18000.00),
(74, '2025-03-19', 'North', 23, 5, 3, 45000.00),
(75, '2025-03-20', 'West', 8, 12, 10, 3500.00),
(76, '2025-03-22', 'East', 8, 18, 13, 450.00),
(77, '2025-03-24', 'North', 9, 17, 12, 60.00),
(78, '2025-03-24', 'South', 9, 10, 6, 2500.00),
(79, '2025-03-25', 'South', 8, 7, 2, 70000.00),
(80, '2025-03-25', 'North', 23, 3, 3, 120000.00);
INSERT INTO dbo.Sales (SaleID, SaleDate, Region, EmployeeID, ProductID, Quantity, UnitPrice) VALUES
(81, '2025-03-27', 'South', 8, 5, 4, 45000.00),
(82, '2025-03-28', 'North', 10, 6, 4, 25000.00),
(83, '2025-03-29', 'East', 10, 8, 4, 15000.00),
(84, '2025-03-30', 'East', 10, 18, 8, 450.00),
(85, '2025-03-31', 'West', 10, 12, 19, 3500.00),
(86, '2025-04-01', 'South', 8, 13, 4, 12000.00),
(87, '2025-04-02', 'West', 9, 9, 2, 1200.00),
(88, '2025-04-05', 'East', 10, 3, 2, 120000.00),
(89, '2025-04-06', 'South', 10, 14, 1, 8500.00),
(90, '2025-04-07', 'North', 10, 1, 4, 65000.00),
(91, '2025-04-08', 'North', 9, 8, 4, 15000.00),
(92, '2025-04-09', 'North', 9, 1, 3, 65000.00),
(93, '2025-04-10', 'East', 10, 5, 1, 45000.00),
(94, '2025-04-11', 'North', 7, 16, 15, 150.00),
(95, '2025-04-13', 'West', 7, 7, 2, 70000.00),
(96, '2025-04-14', 'North', 7, 8, 3, 15000.00),
(97, '2025-04-15', 'North', 7, 14, 4, 8500.00),
(98, '2025-04-16', 'South', 8, 18, 1, 450.00),
(99, '2025-04-16', 'North', 23, 10, 14, 2500.00),
(100, '2025-04-17', 'South', 7, 8, 4, 15000.00),
(101, '2025-04-18', 'West', 10, 3, 1, 120000.00),
(102, '2025-04-20', 'North', 9, 12, 9, 3500.00),
(103, '2025-04-20', 'South', 7, 3, 3, 120000.00),
(104, '2025-04-21', 'East', 23, 5, 1, 45000.00),
(105, '2025-04-22', 'West', 8, 6, 4, 25000.00),
(106, '2025-04-23', 'North', 9, 3, 4, 120000.00),
(107, '2025-04-24', 'North', 9, 2, 2, 85000.00),
(108, '2025-04-25', 'West', 9, 17, 13, 60.00),
(109, '2025-04-27', 'North', 9, 10, 12, 2500.00),
(110, '2025-04-28', 'West', 10, 4, 3, 55000.00),
(111, '2025-04-29', 'South', 10, 13, 3, 12000.00),
(112, '2025-04-29', 'East', 7, 16, 12, 150.00),
(113, '2025-04-30', 'South', 23, 3, 4, 120000.00),
(114, '2025-04-30', 'North', 7, 10, 11, 2500.00),
(115, '2025-05-01', 'West', 23, 10, 10, 2500.00),
(116, '2025-05-02', 'East', 10, 6, 4, 25000.00),
(117, '2025-05-02', 'West', 9, 2, 3, 85000.00),
(118, '2025-05-05', 'South', 7, 12, 17, 3500.00),
(119, '2025-05-05', 'North', 8, 5, 4, 45000.00),
(120, '2025-05-07', 'West', 23, 12, 12, 3500.00);
INSERT INTO dbo.Sales (SaleID, SaleDate, Region, EmployeeID, ProductID, Quantity, UnitPrice) VALUES
(121, '2025-05-09', 'East', 10, 15, 3, 22000.00),
(122, '2025-05-11', 'West', 9, 17, 12, 60.00),
(123, '2025-05-12', 'North', 8, 8, 1, 15000.00),
(124, '2025-05-13', 'North', 9, 17, 13, 60.00),
(125, '2025-05-13', 'South', 23, 9, 15, 1200.00),
(126, '2025-05-14', 'North', 8, 16, 7, 150.00),
(127, '2025-05-16', 'North', 9, 6, 4, 25000.00),
(128, '2025-05-16', 'East', 9, 12, 3, 3500.00),
(129, '2025-05-17', 'South', 7, 6, 3, 25000.00),
(130, '2025-05-18', 'West', 7, 5, 2, 45000.00),
(131, '2025-05-19', 'East', 10, 18, 19, 450.00),
(132, '2025-05-20', 'East', 10, 3, 1, 120000.00),
(133, '2025-05-21', 'West', 23, 17, 14, 60.00),
(134, '2025-05-21', 'East', 7, 3, 2, 120000.00),
(135, '2025-05-22', 'South', 23, 15, 3, 22000.00),
(136, '2025-05-22', 'West', 23, 6, 2, 25000.00),
(137, '2025-05-25', 'South', 9, 10, 6, 2500.00),
(138, '2025-05-26', 'East', 7, 12, 17, 3500.00),
(139, '2025-05-27', 'South', 9, 7, 3, 70000.00),
(140, '2025-05-29', 'East', 23, 5, 2, 45000.00),
(141, '2025-06-03', 'North', 10, 7, 4, 70000.00),
(142, '2025-06-04', 'South', 10, 10, 16, 2500.00),
(143, '2025-06-05', 'North', 8, 15, 1, 22000.00),
(144, '2025-06-06', 'West', 8, 14, 4, 8500.00),
(145, '2025-06-06', 'East', 9, 11, 2, 18000.00),
(146, '2025-06-07', 'East', 23, 13, 2, 12000.00),
(147, '2025-06-09', 'North', 9, 8, 4, 15000.00),
(148, '2025-06-10', 'North', 7, 8, 2, 15000.00),
(149, '2025-06-10', 'West', 8, 10, 13, 2500.00),
(150, '2025-06-11', 'South', 8, 11, 3, 18000.00),
(151, '2025-06-12', 'West', 9, 17, 15, 60.00),
(152, '2025-06-12', 'North', 10, 16, 1, 150.00),
(153, '2025-06-13', 'East', 7, 8, 2, 15000.00),
(154, '2025-06-13', 'West', 23, 2, 3, 85000.00),
(155, '2025-06-14', 'North', 7, 10, 18, 2500.00),
(156, '2025-06-14', 'East', 9, 14, 2, 8500.00),
(157, '2025-06-15', 'West', 7, 12, 2, 3500.00),
(158, '2025-06-15', 'East', 23, 18, 7, 450.00),
(159, '2025-06-16', 'West', 23, 3, 4, 120000.00),
(160, '2025-06-17', 'North', 10, 4, 2, 55000.00);
INSERT INTO dbo.Sales (SaleID, SaleDate, Region, EmployeeID, ProductID, Quantity, UnitPrice) VALUES
(161, '2025-06-18', 'South', 8, 11, 3, 18000.00),
(162, '2025-06-19', 'North', 7, 17, 2, 60.00),
(163, '2025-06-19', 'West', 23, 5, 3, 45000.00),
(164, '2025-06-20', 'East', 23, 5, 2, 45000.00),
(165, '2025-06-20', 'West', 23, 11, 2, 18000.00),
(166, '2025-06-21', 'East', 10, 11, 4, 18000.00),
(167, '2025-06-23', 'West', 23, 11, 1, 18000.00),
(168, '2025-06-24', 'East', 23, 1, 4, 65000.00),
(169, '2025-06-25', 'South', 23, 2, 4, 85000.00),
(170, '2025-06-26', 'North', 23, 5, 2, 45000.00),
(171, '2025-06-26', 'North', 10, 4, 2, 55000.00),
(172, '2025-06-27', 'West', 8, 14, 2, 8500.00),
(173, '2025-06-28', 'West', 7, 17, 20, 60.00),
(174, '2025-06-28', 'East', 10, 5, 2, 45000.00),
(175, '2025-06-29', 'West', 23, 11, 2, 18000.00),
(176, '2025-06-29', 'East', 23, 11, 3, 18000.00),
(177, '2025-06-30', 'East', 23, 7, 2, 70000.00),
(178, '2025-06-30', 'East', 9, 10, 8, 2500.00);
SET IDENTITY_INSERT dbo.Sales OFF;
-- Preview: first 10 sales
SELECT TOP (10) * FROM dbo.Sales ORDER BY SaleID;
GO
Output
| SaleID | SaleDate | Region | EmployeeID | ProductID | Quantity | UnitPrice | TotalAmount |
|---|---|---|---|---|---|---|---|
| 1 | 2025-01-02 | South | 10 | 3 | 2 | 120000.00 | 240000.00 |
| 2 | 2025-01-02 | North | 10 | 18 | 12 | 450.00 | 5400.00 |
| 3 | 2025-01-04 | West | 9 | 18 | 4 | 450.00 | 1800.00 |
| 4 | 2025-01-05 | North | 8 | 13 | 3 | 12000.00 | 36000.00 |
| 5 | 2025-01-06 | South | 7 | 1 | 3 | 65000.00 | 195000.00 |
| 6 | 2025-01-06 | West | 7 | 15 | 3 | 22000.00 | 66000.00 |
| 7 | 2025-01-07 | East | 10 | 2 | 1 | 85000.00 | 85000.00 |
| 8 | 2025-01-10 | West | 10 | 18 | 5 | 450.00 | 2250.00 |
| 9 | 2025-01-11 | South | 10 | 18 | 14 | 450.00 | 6300.00 |
| 10 | 2025-01-13 | North | 9 | 14 | 3 | 8500.00 | 25500.00 |
Quick check: row counts of all core tables
SELECT 'Departments' AS TableName, COUNT(*) AS TotalRows FROM dbo.Departments UNION ALL
SELECT 'Employees', COUNT(*) FROM dbo.Employees UNION ALL
SELECT 'Customers', COUNT(*) FROM dbo.Customers UNION ALL
SELECT 'Categories', COUNT(*) FROM dbo.Categories UNION ALL
SELECT 'Products', COUNT(*) FROM dbo.Products UNION ALL
SELECT 'Orders', COUNT(*) FROM dbo.Orders UNION ALL
SELECT 'OrderItems', COUNT(*) FROM dbo.OrderItems UNION ALL
SELECT 'Sales', COUNT(*) FROM dbo.Sales;
GO
Output
| TableName | TotalRows |
|---|---|
| Departments | 8 |
| Employees | 25 |
| Customers | 20 |
| Categories | 11 |
| Products | 20 |
| Orders | 80 |
| OrderItems | 202 |
| Sales | 178 |