Podcast
Questions and Answers
What does the following SQL Server query return? SELECT DATEDIFF(day, '2023-01-01', '2023-01-15');
What does the following SQL Server query return? SELECT DATEDIFF(day, '2023-01-01', '2023-01-15');
What is the purpose of the IDENTITY
property in SQL Server?
What is the purpose of the IDENTITY
property in SQL Server?
Which of the following is true regarding a clustered index in SQL Server?
Which of the following is true regarding a clustered index in SQL Server?
What is the result of the following query in SQL Server? SELECT REPLICATE('SQL', 3);
What is the result of the following query in SQL Server? SELECT REPLICATE('SQL', 3);
Signup and view all the answers
What does the WITH
keyword do in a SQL Server query when used with a subquery?
What does the WITH
keyword do in a SQL Server query when used with a subquery?
Signup and view all the answers
What is the role of the COALESCE
function in SQL Server?
What is the role of the COALESCE
function in SQL Server?
Signup and view all the answers
What is the purpose of the CASE
statement in SQL Server?
What is the purpose of the CASE
statement in SQL Server?
Signup and view all the answers
What will happen if a DELETE statement in SQL Server is executed without a WHERE clause?
What will happen if a DELETE statement in SQL Server is executed without a WHERE clause?
Signup and view all the answers
Which of the following is used to store unstructured data, such as text files, in SQL Server?
Which of the following is used to store unstructured data, such as text files, in SQL Server?
Signup and view all the answers
What does the following query return in SQL Server? SELECT TOP(5) * FROM Orders ORDER BY OrderDate DESC;
What does the following query return in SQL Server? SELECT TOP(5) * FROM Orders ORDER BY OrderDate DESC;
Signup and view all the answers
Which of the following is true about SQL Server transactions?
Which of the following is true about SQL Server transactions?
Signup and view all the answers
What is the purpose of the UNION
operator in SQL Server?
What is the purpose of the UNION
operator in SQL Server?
Signup and view all the answers
How can you force the query optimizer to use a specific index in SQL Server?
How can you force the query optimizer to use a specific index in SQL Server?
Signup and view all the answers
What does the following query accomplish? SELECT DISTINCT Name FROM Customers;
What does the following query accomplish? SELECT DISTINCT Name FROM Customers;
Signup and view all the answers
Which of the following is true regarding table variables in SQL Server?
Which of the following is true regarding table variables in SQL Server?
Signup and view all the answers
What is the purpose of the ROW_NUMBER()
function in SQL Server?
What is the purpose of the ROW_NUMBER()
function in SQL Server?
Signup and view all the answers
What is the difference between CHAR
and VARCHAR
in SQL Server?
What is the difference between CHAR
and VARCHAR
in SQL Server?
Signup and view all the answers
Study Notes
SQL Server Query Functions and Operators
-
DATEDIFF
: Returns the difference in days between two dates. Example:'2023-01-01'
to'2023-01-15'
yields 14 days. -
IDENTITY
property: Automatically generates unique numeric values for new rows, ensuring uniqueness for primary keys. - Clustered Index: Stores data rows in sorted order based on indexed columns, enhancing query performance when accessing sorted data.
String and Data Manipulation Functions
-
REPLICATE
: Duplicates a specified string a defined number of times. Example:REPLICATE('SQL', 3)
returns'SQLSQLSQL'
. -
COALESCE
: Returns the first non-NULL value from the list of expressions provided. -
CASE
statement: Allows conditional logic within SQL queries, enabling branching decisions based on certain criteria.
SQL Server Data Modification and Transactions
- A
DELETE
statement executed without aWHERE
clause removes all records from the specified table. - Transactions: Automatically commit if no errors occur, ensuring data integrity during batch operations.
Data Retrieval and Result Set Operations
-
TOP(n)
: Limits the number of records returned by a query. Example:SELECT TOP(5) FROM Orders ORDER BY OrderDate DESC
returns the five most recent orders. -
UNION
: Combines results from multiple queries, returning all distinct rows from the involved sets.
Indexing and Query Optimization
-
INDEX
hint: Forces SQL Server to use a specific index during query execution to enhance performance. - Table variables: Stored in memory, often resulting in faster access than temporary tables; however, they have limitations with large data and transaction support.
SQL Data Types and Lengths
-
CHAR
vsVARCHAR
:CHAR
is fixed-length, suited for data of known lengths, whileVARCHAR
is variable-length, more flexible for different data sizes.
Special Functions
-
ROW_NUMBER()
: Generates a sequential integer for each row in the result set, starting at one, useful for pagination.
Miscellaneous SQL Facts
- Distinct records:
SELECT DISTINCT
filters duplicate values in a query result, e.g., unique customer names from the Customers table.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Test your knowledge on SQL Server fundamentals with this quiz. It includes questions about date functions, identity properties, and more. Perfect for beginners and those looking to refresh their skills.