Introduction to Microsoft SQL Server – What Is SQL Server?
Quick Answer: Microsoft SQL Server is a relational database management system (RDBMS). It stores data in related tables and lets applications retrieve and manage that data using SQL and T-SQL.
1. Why Do We Need Microsoft SQL Server?
Imagine Priya manages a grocery shop with 1,000 daily orders. Every order contains products, quantities, prices and customer details.
She needs to store every order and find old records quickly. She also needs accurate totals when many customers place orders.
Can she manage everything using separate files and handwritten registers?
The problem without SQL Server
Priya could keep order information inside her application memory. This works for a small demonstration, but it does not provide permanent database storage.
Example 1: Store grocery orders in application memory
This C# example stores three orders only while the application runs.
var orders = new List<string>
{
"Rice - 1200",
"Sugar - 800",
"Milk - 600"
};
foreach (var order in orders)
{
Console.WriteLine(order);
}
Expected output
Rice - 1200 Sugar - 800 Milk - 600
This example displays the orders correctly. However, the design has problems.
- Application memory is lost when the application stops.
- Multiple application instances cannot share this list directly.
- Finding related customer and order information becomes harder.
- Managing concurrent updates needs additional application logic.
Now imagine Priya handling 1,000 orders every day. She needs permanent storage and reliable access.
We need a database that stores information beyond application memory. We also need a common way to retrieve related records.
The solution: Microsoft SQL Server
Database = an organized collection of stored information.
RDBMS = software that manages related data in tables.
SQL = a language used to communicate with a database.
T-SQL = Microsoft's SQL extension with additional programming features.
SQL Server stores Priya's orders in database tables. Her application can insert, retrieve and update those records.
Animation 1: How SQL Server manages grocery orders
Follow Priya's order from the shop application to stored database records.
Priya enters three orders. SQL Server stores them and returns records when requested.
2. Implement SQL Server with T-SQL
Let's create a database for Priya's grocery shop.
Database = a separate storage area for related business information.
Table = a structure that stores records using rows and columns.
Primary Key = a column that uniquely identifies each table record.
Create a grocery database
Example 2: Create a database, table and grocery orders
Run this script in a SQL Server query window.
CREATE DATABASE GroceryDB;
GO
USE GroceryDB;
GO
CREATE TABLE Orders
(
OrderId INT PRIMARY KEY,
Product VARCHAR(50),
Amount DECIMAL(10, 2)
);
GO
INSERT INTO Orders
(OrderId, Product, Amount)
VALUES
(101, 'Rice', 1200),
(102, 'Sugar', 800),
(103, 'Milk', 600);
GO
SELECT OrderId, Product, Amount
FROM Orders;
GO
Notice CREATE DATABASE creates the database. The CREATE TABLE statement defines its order structure.
The INSERT statement saves three orders. The SELECT statement retrieves those stored records.
Expected output
OrderId Product Amount ------- ------- ------ 101 Rice 1200.00 102 Sugar 800.00 103 Milk 600.00
Important: Run this script on a SQL Server instance. SQL Server must be installed and accessible before execution.
3. Quick Summary
Without SQL Server vs with SQL Server
| Without SQL Server | With SQL Server |
|---|---|
| Application memory stores records. | Database stores records permanently. |
| Sharing data needs extra logic. | Applications can access shared database records. |
| Relationships need application logic. | Tables can use primary and foreign keys. |
| Database features are unavailable. | Supports transactions, indexes and security. |
The important terms to remember
- SQL Server: Microsoft's relational database management system.
- RDBMS: Software that manages related tables.
- SQL: Language used to communicate with databases.
- T-SQL: Microsoft's SQL programming extension.
- Database table: Rows and columns used to store information.
4. Common Mistakes and Best Practices
1. Confusing SQL with SQL Server
SQL is a language. SQL Server is software that manages databases.
Better approach: Understand the difference before writing database queries.
2. Thinking application memory is permanent storage
Application memory usually disappears when its process stops.
Better approach: Store important business records in a persistent database.
3. Ignoring database design
Storing every business detail in one table can create duplication.
Better approach: Design related tables and use appropriate keys.
5. How SQL Server Comes Up in Interviews
Question 1: What is Microsoft SQL Server?
What the interviewer expects: Explain its purpose and main features.
Strong answer: "SQL Server is Microsoft's relational database management system. It stores data in related tables and supports SQL queries, transactions, security and data recovery."
Question 2: What is the difference between SQL and T-SQL?
What the interviewer expects: Explain Microsoft's SQL extension.
Strong answer: "SQL is a language for working with databases. T-SQL extends SQL with variables, conditions, procedures and error handling."
Question 3: What is an RDBMS?
What the interviewer expects: Explain relational data storage.
Strong answer: "An RDBMS stores information in related tables. We use keys to connect records and maintain data integrity."
6. Hands-On Practice
Beginner: School database
Create a database named SchoolDB. Create a Students table with StudentId, StudentName and Class.
Expected result: Insert and retrieve three student records.
Intermediate: Grocery database
Extend Priya's database with a Customers table. Connect customer records with grocery orders.
Hint: Use Primary Key and Foreign Key constraints.
Advanced: Hospital database
Create a database for Lakshmi's hospital administration work.
- Create Patients and Appointments tables.
- Connect appointments with patient records.
- Retrieve appointments for each patient.
Challenge: Design the tables without repeating patient information.
7. Next Steps and Community
Previous article: None. This is the first article in the SQL Server series.
Next article: Installing SQL Server and Setting Up SQL Server Management Studio (SSMS)
For more details, read the official Microsoft documentation:
Try Priya's grocery database example and add more products. Share your table design and queries with other learners.