SQL Server Multiple Choice Questions
Test your SQL Server knowledge with these comprehensive multiple-choice questions. Hover over any question to reveal the correct answer.
Jump to Section:
1. Introduction to SQL
1. What does SQL stand for?
Easy
Answer: A. Structured Query Language
2. Which of these is NOT a SQL sublanguage?
Easy
Answer: D. DTL
3. Which SQL command is used to define database structures?
Medium
Answer: B. Data Definition Language
4. What was the original purpose of SQL?
Medium
Answer: B. To provide an interface for relational databases
5. Which organization first standardized SQL?
Hard
Answer: B. ANSI
2. Setting Up SQL Server Environment
6. Which tool is the primary GUI for SQL Server administration?
Easy
Answer: A. SQL Server Management Studio (SSMS)
7. What is the default port for SQL Server?
Easy
Answer: A. 1433
8. Which command displays version information in SQL Server?
Medium
Answer: B. SELECT @@VERSION;
9. What is the SQL Server equivalent of MySQL's LIMIT clause?
Medium
Answer: A. TOP (or D. OFFSET-FETCH for more complex scenarios)
10. Which authentication mode is more secure in SQL Server?
Hard
Answer: A. Windows Authentication
3. Database Operations
11. Which command creates a new database in SQL Server?
Easy
Answer: B. CREATE DATABASE
12. How do you list all databases in SQL Server?
Easy
Answer: B. SELECT name FROM sys.databases;
13. Which command selects a database to work with in SQL Server?
Medium
Answer: A. USE database_name;
14. What does the DROP DATABASE command do in SQL Server?
Medium
Answer: B. Deletes a database permanently
15. Which function displays the currently selected database in SQL Server?
Hard
Answer: B. SELECT DB_NAME();
4. Basic SQL Queries
16. Which SQL keyword retrieves data from a database?
Easy
Answer: B. SELECT
17. Which clause filters records in a SELECT statement?
Easy
Answer: B. WHERE
18. What does the asterisk (*) represent in a SELECT statement?
Medium
Answer: A. All columns in the table
19. Which keyword eliminates duplicate rows from the result?
Medium
Answer: B. DISTINCT
20. What is the purpose of the ORDER BY clause?
Hard
Answer: C. To sort the result set
5. Modifying Data (DML)
21. Which statement inserts new data into a table?
Easy
Answer: B. INSERT INTO
22. Which statement modifies existing records?
Easy
Answer: C. UPDATE
23. Which statement removes records from a table?
Medium
Answer: B. DELETE
24. What is the difference between DELETE and TRUNCATE in SQL Server?
Medium
Answer: C. DELETE can use a WHERE clause (and D is also correct in SQL Server)
25. Which clause is used with UPDATE to specify which records to modify?
Hard
Answer: B. WHERE
6. Advanced Filtering
26. Which operator searches for a specified pattern in a column?
Easy
Answer: A. LIKE
27. Which wildcard represents any single character in a LIKE clause?
Medium
Answer: B. _ (underscore)
28. Which operator is used to combine multiple conditions in a WHERE clause?
Easy
Answer: A. AND
29. What does the BETWEEN operator do?
Medium
Answer: A. Checks if a value is within a range
30. Which clause is used to filter groups after GROUP BY is applied?
Hard
Answer: C. HAVING
7. Working with Multiple Tables
31. Which join returns all rows when there is a match in either table?
Medium
Answer: D. FULL OUTER JOIN
32. What is the purpose of a foreign key?
Medium
Answer: B. To create a relationship between tables
33. Which join returns only matching rows from both tables?
Easy
Answer: A. INNER JOIN
34. What is a self-join?
Hard
Answer: A. Joining a table to itself
35. Which join returns all rows from the left table and matched rows from the right table?
Medium
Answer: B. LEFT JOIN
8. Aggregation and Grouping
36. Which function returns the average value of a numeric column?
Easy
Answer: B. AVG()
37. What is the difference between WHERE and HAVING clauses?
Hard
Answer: D. All of the above
38. Which function counts the number of rows in a result set?
Easy
Answer: B. COUNT()
39. What does GROUP BY do?
Medium
Answer: B. Groups rows by column values
40. Which function returns the highest value in a column?
Easy
Answer: B. MAX()
9. Subqueries
41. What is a subquery in SQL?
Medium
Answer: B. A query nested inside another query
42. Which operator compares a value to a list from a subquery?
Medium
Answer: B. IN
43. What is a correlated subquery?
Hard
Answer: A. A subquery that references the outer query
44. Which clause can contain a subquery in a SELECT statement?
Medium
Answer: D. All of the above
45. What is the purpose of EXISTS with subqueries?
Hard
Answer: A. To check if a subquery returns any rows
10. Views and Indexes
46. What is a view in SQL?
Medium
Answer: B. A virtual table based on a SELECT
47. What is the main purpose of an index?
Medium
Answer: B. To improve query performance
48. Which statement creates a view?
Easy
Answer: B. CREATE VIEW
49. What is a clustered index in SQL Server?
Hard
Answer: A. An index that determines the physical order of data
50. Which statement creates an index?
Medium
Answer: B. CREATE INDEX
11. Basic SQL Functions
51. Which function returns the current date and time in SQL Server?
Easy
Answer: D. All of the above (All work in SQL Server)
52. Which function is used to concatenate strings in SQL Server?
Easy
Answer: C. Both A and B (CONCAT() and + both work in SQL Server)
53. Which function converts a string to uppercase in SQL Server?
Easy
Answer: A. UPPER() (UCASE() is not valid in SQL Server)
54. What does the ISNULL() function do in SQL Server?
Medium
Answer: B. Replaces NULL with a specified value
55. Which function extracts a portion of a string in SQL Server?
Medium
Answer: B. SUBSTRING()
12. Transactions and ACID
56. Which SQL statement starts a transaction in SQL Server?
Medium
Answer: C. Both A and B (Both are valid in SQL Server)
57. What does the "A" in ACID stand for?
Medium
Answer: B. Atomicity
58. Which statement permanently saves a transaction's changes?
Easy
Answer: B. COMMIT
59. What does the "I" in ACID represent?
Medium
Answer: B. Isolation
60. Which statement undoes a transaction's changes?
Easy
Answer: B. ROLLBACK
13. Stored Procedures
61. What is a stored procedure?
Medium
Answer: A. A precompiled collection of SQL statements
62. Which statement creates a stored procedure in SQL Server?
Hard
Answer: A. CREATE PROCEDURE
63. How do you execute a stored procedure in SQL Server?
Easy
Answer: C. Both A and B (EXECUTE and EXEC both work in SQL Server)
64. What is an advantage of stored procedures?
Medium
Answer: D. All of the above
65. Which statement modifies an existing stored procedure in SQL Server?
Hard
Answer: C. ALTER PROCEDURE