C# Mastery Hub
Home
Challenges
Discussion
Lessons
Core Topics
C# Fundamentals
Console Applications
Classes & OOP
Windows Forms
ASP.NET Core
SQL Server
VS & SQL Connection
RDLC Reports
.NET MAUI
Getting Started
Getting Started
Website Development
SEO Guide
Security
Project Workflow
Extra Topics
Cloud & Deployment
AWS Cloud
Deployment
About
Contact
Test Your Knowledge
SQL Server Quiz
Answer all questions to test your understanding
1
What is SSMS used for?
Managing SQL Server databases
Writing C# code
Building websites
Creating mobile apps
2
What is the purpose of Object Explorer in SSMS?
To navigate and manage database objects
To write queries
To debug code
To design web pages
3
What command checks the SQL Server version?
SELECT @@VERSION
SELECT VERSION
SHOW VERSION
GET VERSION
4
What shortcut runs a query in SSMS?
F5
Ctrl+S
F10
Ctrl+R
5
Which databases are system databases in SQL Server?
master, model, msdb, tempdb
user1, user2, user3
system1, system2
data1, data2, data3
6
What command creates a new database?
CREATE DATABASE
NEW DATABASE
ADD DATABASE
MAKE DATABASE
7
What does IDENTITY(1,1) do in a table definition?
Auto-increments the column starting from 1
Creates a primary key
Adds a foreign key
Makes the column nullable
8
What is the purpose of a PRIMARY KEY?
Uniquely identifies each row
Links two tables together
Allows duplicate values
Speeds up queries
9
What does NOT NULL mean in SQL?
The column cannot be empty
The column can be empty
The column must be unique
The column is a primary key
10
What command shows the structure of a table?
EXEC sp_help 'TableName'
SHOW TABLE TableName
DESCRIBE TableName
VIEW TableName
11
What does UNIQUE do in SQL?
Ensures no two rows have the same value in that column
Allows duplicate values
Creates a primary key
Creates a foreign key
12
Which data type is used for whole numbers?
INT
DECIMAL
NVARCHAR
DATE
13
Which data type is used for text with variable length?
NVARCHAR
INT
DECIMAL
BIT
14
Which data type is used for money/decimal values?
DECIMAL
INT
NVARCHAR
DATE
15
What is the purpose of a CHECK constraint?
Restricts values to a valid range
Creates a primary key
Creates a foreign key
Allows null values
16
What is the purpose of a FOREIGN KEY constraint?
Enforces that a value must exist in another table
Creates a primary key
Restricts values to a range
Allows duplicates
17
What is DECIMAL(10,2) used for?
Numbers with 10 total digits and 2 decimal places
Numbers with 10 decimal places
Numbers up to 10
Text with 10 characters
18
What does SELECT * FROM Students do?
Returns all columns from the Students table
Returns only the first column
Deletes the Students table
Creates a new table
19
What is the purpose of WHERE in SQL?
Filters rows based on a condition
Sorts the results
Groups the results
Adds new rows
20
What does ORDER BY do?
Sorts the results
Filters the results
Groups the results
Adds new rows
21
What does ORDER BY LastName DESC do?
Sorts by LastName in descending order
Sorts by LastName in ascending order
Filters by LastName
Deletes rows with LastName
22
Which clause filters rows based on a condition?
WHERE
ORDER BY
SELECT
GROUP BY
23
What does INNER JOIN do?
Returns only matching rows from both tables
Returns all rows from the left table
Returns all rows from both tables
Deletes matching rows
24
What does LEFT JOIN do?
Returns all rows from the left table, matched or not
Returns only matching rows
Returns all rows from both tables
Returns only rows from the right table
25
When should you use LEFT JOIN?
When you want all rows from the main table even if there's no match
When you only want matching rows
When you want to delete data
When you want to insert data
26
What is the difference between INNER JOIN and LEFT JOIN?
INNER JOIN returns only matches, LEFT JOIN returns all rows from the left table
They are the same
INNER JOIN is faster
LEFT JOIN is faster
27
Which join returns all rows from both tables, matched where possible?
FULL JOIN
INNER JOIN
LEFT JOIN
RIGHT JOIN
28
What does INSERT do?
Adds new rows to a table
Modifies existing rows
Removes rows from a table
Creates a new table
29
What does UPDATE do?
Modifies existing rows
Adds new rows
Removes rows
Creates a new table
30
What does DELETE do?
Removes rows from a table
Adds new rows
Modifies existing rows
Creates a new table
31
What is the most important rule for UPDATE and DELETE?
Always use a WHERE clause
Always use ORDER BY
Always use SELECT first
Always use JOIN
32
How can you safely test a DELETE statement?
Run SELECT with the same WHERE clause first
Run the DELETE and hope for the best
Use a transaction
Backup the database
33
What is a stored procedure?
Precompiled T-SQL saved in the database
A function that returns a value
A view that shows data
A type of table
34
Why use stored procedures?
They prevent SQL injection and improve performance
They are slower than inline SQL
They can't be reused
They are less secure
35
How do you call a stored procedure?
EXEC ProcedureName
SELECT ProcedureName
CALL ProcedureName
RUN ProcedureName
36
What command creates a stored procedure?
CREATE PROCEDURE
CREATE FUNCTION
CREATE VIEW
CREATE TABLE
37
How do stored procedures prevent SQL injection?
Parameters are never concatenated into the query text
They are not executed
They delete all user input
They only allow SELECT statements
38
What is a scalar function?
A function that returns a single value
A function that returns a table
A function that returns a view
A function that returns nothing
39
What is a view in SQL Server?
A saved query that acts like a virtual table
A stored procedure
A function
A physical table
40
What is a table-valued function?
A function that returns a table
A function that returns a single value
A function that returns a view
A function that returns nothing
41
Can you use WHERE on a view?
Yes, views behave like tables for SELECT
No, views cannot be filtered
Only with stored procedures
Only with functions
42
What is the difference between a view and a table?
A view is a saved query, a table stores data
A view stores data, a table is a query
They are the same
Views are faster than tables
43
What is the purpose of an index?
To speed up data retrieval
To slow down queries
To delete data
To store data
44
What is the downside of having too many indexes?
They slow down INSERT, UPDATE, and DELETE
They speed up everything
They have no downside
They use no storage
45
Which columns should you index?
Columns you frequently filter or sort by
All columns
Only primary keys
Only foreign keys
46
What is a composite index?
An index on multiple columns
An index on one column
An index that is always unique
An index on a view
47
Does a PRIMARY KEY have an index automatically?
Yes, SQL Server creates one automatically
No, you must create one manually
Only for VARCHAR columns
Only for INT columns
48
What is a transaction?
A group of statements that all succeed or fail together
A single statement
A type of index
A view
49
What does COMMIT do?
Saves the transaction permanently
Undoes the transaction
Cancels the transaction
Pauses the transaction
50
What does ROLLBACK do?
Undoes all changes in the transaction
Saves the transaction
Pauses the transaction
Starts a new transaction
51
What does the 'A' in ACID stand for?
Atomicity
Availability
Accuracy
Authenticity
52
What does the 'D' in ACID stand for?
Durability
Data
Database
Default
53
What should you use to handle errors in a transaction?
TRY-CATCH with ROLLBACK
Ignore errors
COMMIT on error
DELETE on error
Submit Quiz