Certification Practice Test Sample Questions For
Querying Data with Microsoft Transact-SQL (MS-20761)
QuickStart is now offering you sample questions for Querying Data with Microsoft Transact-SQL (MS-20761). Whether you are deciding which exam to sign up for, or simply want to practice the materials necessary to complete certification for this course, we have provided a practice test to better aid in certification. 100% of the questions are real test questions from a recent version of the Querying Data with Microsoft Transact-SQL (MS-20761) exam.
SQL: Advanced Querying (SQL-QueryAdv)
Enroll now today and get 30% off using discount code PRACTICE30 at checkout.
Querying Data with Microsoft Transact-SQL (MS-20761) Sample Exam Questions
Module 1
Introduction to MS SQL Server
SQL Server includes 5 System Databases. Which one of the following is used only for Reporting Services?
Among 4 different editions of SQL Server, which of the following has support for Always on High Availability?
- A. Enterprise,
-
Correct!
- B. Standard,
-
Incorrect.
- C. Business Intelligence
-
Incorrect.
- D. None of the above
-
Incorrect.
Which authentication method can be used to log on to SQL Server?
- A. Windows Authentication
-
Incorrect.
- B. SQL Server Authentication
-
Incorrect.
- C. Both A And B
-
Correct!
- D. None of the above
-
Incorrect.
Back To Top
Module 2
Introduction to T-SQL Querying
SQL Server Database Engine Processes Select Statement in a logical manner. Choose the best answer that describes the correct Logical Query Processing Order.
- A. SELECT, ORDER BY, WHERE, GROUP BY, HAVING, FROM
-
Incorrect.
- B. FROM, SELECT, WHERE, GROUP BY, HAVING, ORDER BY.
-
Incorrect.
- C. FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY.
-
Correct!
- D. FROM, WHERE, GROUP BY, SELECT, HAVING, ORDER BY.
-
Incorrect.
From the following T-SQL Elements select the one that can include a Predicate:
- A. Where Clause
-
Incorrect.
- B. Having Clause
-
Incorrect.
- C. Join Conditions
-
Incorrect.
- D. All the Above
-
Correct!
Which of the following Statements are True with regards to Categories of T-SQL?
- A. DML statements are focused only on Managing security and Permissions such as GRANT, REVOKE and DENY.
-
Incorrect.
- B. DCL statements handles lifecycle of database objects such as tables, views and procedures.
-
Incorrect.
- C. DDL statements include CREATE, ALTER, AND DROP
-
Correct!
- F. None of the Above
-
Incorrect.
Back To Top
Module 3
Writing Select Queries
Consider the following Query: Select unit price, qty, (unit price*qty) From Sales. OrderDetails;
The Results appear as follows:
Choose the best answer which describes the error in the above Results:
- A. Column Alias is missing from the third column
-
Incorrect.
- C. All of the Above
-
Incorrect.
- D. None of the above
-
Incorrect.
You have company departments in five countries. You have the following query for the Human Resource Database:
SELECT DISTINCT DeptName, Country from HumanResources.Departments;
The Query Returns the following:
How many rows would be returned?
Which of the following statements are correct regarding T-SQL Case Expressions?
- A. There are three types of Case Expressions in T-SQL
-
Incorrect.
- C. None of the above
-
Correct!
Back To Top
Module 4
Querying Multiple Tables
Choose which of the following join types description is true?
- B. The FULL OUTER JOIN returns all records when there is a match in either left or right table
-
Correct!
- D. None of the above
-
Incorrect.
What is the purpose of using Self Joins? Chose the best answer/s below:
- A. To compare rows in same table to each other
-
Incorrect.
- C. All the above
-
Correct!
- D. None of the above.
-
Incorrect.
Consider the following Query:
“From T1 Left Outer Join t2 ON t1.col=t2.col”
Choose the correct answer that best describes the above query:
- D. None of the above
-
Incorrect.
Back To Top
Module 5
Sorting and Filtering Data
The main purpose of order by clause is to?
- A. Sort rows in results for presentation purposes.
-
Correct!
- B. Declare Sort Order with ASC or DESC
-
Incorrect.
- C. All the above
-
Incorrect.
- D. None of the above
-
Incorrect.
Let’s assume you are filtering data in the where clause? Which of the following statement/s is/are true?
- C. Can be optimized by SQL Server to use Indexes
-
Incorrect.
- D. A and C only
-
Correct!
Chose the answer below which states the error in the following Query:
SELECT TOP (5) ordereid, custid, orderdate From Sales. Orders
- A. Where clause is missing
-
Incorrect.
- B. Order by Clause is Missing
-
Correct!
- C. All the Above
-
Correct!
- D. None of the above.
-
Incorrect.
Back To Top
Module 6
Working with SQL Server Data Types
In Certain scenarios we must convert from one data type to another But, there are important reasons for data type conversion. Listed below are some options, Chose the answer/s which you think is correct:
- A. When data is moved, combined or compared with other data
-
Incorrect.
- B. When we have to assign a variable.
-
Correct!
- C. All the above
-
Incorrect.
- D. None of the above
-
Incorrect.
Collation is a collection of properties that determine several aspects of character data. Which property is/are not a property of Collation?
- A. Character Length
-
Correct!
- B. Character Set
-
Incorrect.
- C. Sort Order
-
Incorrect.
- D. None of the above
-
Incorrect.
This question comprises of three parts. First part is about date functions, second part about Date and Time Parts Functions, and third part will focus on date and time difference Functions. For each part, one question with 4 options will be given. You to have to choose the option which best answers the question:
Part 1: Date Functions:
*Following Function is used to get system dates:
- A. DateName
-
Incorrect.
- B. GetDate/GetUTCDate
-
Correct!
- C. All the Above
-
Correct!
- D. None of the above.
-
Incorrect.
Part 2: Date and Time Parts Function:
*Following function is used to get Date and Time Parts:
- A. DATEPART
-
Incorrect.
- B. DateName
-
Correct!
- C. All the Above
-
Correct!
- D. None of the above.
-
Incorrect.
Part 3: Date and time difference functions:
*Following function is used to get date and time difference:
- A. DATEFROMPARTS
-
Incorrect.
- B. DATEDIFF/DATEDIFF_BIG
-
Correct!
- C. All the Above
-
Incorrect.
- D. None of the above.
-
Incorrect.
Back To Top
Module 7
Using DML To Modify Data
Which of the following statements are true about Select Into clause:
- C. Creates an output table.
-
Incorrect.
- D. None of the above
-
Incorrect.
Choose all the statements which are correct about Merge clause:
- D. All the above
-
Incorrect.
This question comprises of three parts. First part is about date functions, second part about Date and Time Parts Functions, and third part will focus on date and time difference Functions. For each part, one question with 4 options will be given. You to have to choose the option which best answers the question:
Part 1: Date Functions:
*Following Function is used to get system dates:
- A. DateName
-
Incorrect.
- B. GetDate/GetUTCDate
-
Correct!
- C. All the Above
-
Correct!
- D. None of the above.
-
Incorrect.
Part 2: Date and Time Parts Function:
*Following function is used to get Date and Time Parts:
- A. DATEPART
-
Incorrect.
- B. DateName
-
Correct!
- C. All the Above
-
Correct!
- D. None of the above.
-
Incorrect.
Part 3: Date and time difference functions:
*Following function is used to get date and time difference:
- A. DATEFROMPARTS
-
Incorrect.
- B. DATEDIFF/DATEDIFF_BIG
-
Correct!
- C. All the Above
-
Incorrect.
- D. None of the above.
-
Incorrect.
Back To Top
Module 8
Using Built-In Functions
Scalar functions in SQL Server can be defined as:
- A. Operates on elements, from multiple rows as inputs and return a single value as output.
-
Incorrect.
- B. Return a single scalar value
-
Correct!
- C. Can be used like an expression in queries
-
Correct!
- D. None of the above
-
Incorrect.
In addition to data type conversions, SQL Server provides functions for conversion or replacement of NULL. Which function is used to replace NULL input with another value?
- A. ISNULL
-
Incorrect.
- B. COALESCE
-
Incorrect.
- C. Both A and B
-
Correct!
- D. None of the above
-
Incorrect.
Back To Top
Module 9
Grouping and Aggregating Data
Which clause/s is/are processed after Group By clause?
Which of the following statement/s is/are true about Aggregate functions?
- C. Aggregate functions in a SELECT list do not generate a column alias. You may wish to use the AS clause to provide one
-
Incorrect.
- D. All of the above
-
Correct!
Answer the following two questions:
1) Which clause only operates on Groups and not detail rows?
- A. Having
-
Incorrect.
- B. Group By
-
Correct!
- C. All the Above
-
Incorrect.
- D. None of the above.
-
Incorrect.
2) Which clause controls which rows are available for the next phase of the query?
- A. Having
-
Incorrect.
- B. DateName
-
Correct!
- C. All the Above
-
Correct!
- D. None of the above.
-
Incorrect.
Part 3: Date and time difference functions:
*Following function is used to get date and time difference:
- A. DATEFROMPARTS
-
Incorrect.
- B. DATEDIFF/DATEDIFF_BIG
-
Correct!
- C. All the Above
-
Incorrect.
- D. None of the above.
-
Incorrect.
Back To Top
Module 10
Using Subqueries
Subqueries can either be:
- A. Scalar.
-
Incorrect.
- B. Multi-valued
-
Incorrect.
- C. Table-valued
-
Incorrect.
- D. All the above
-
Correct!
Choose all the correct statements regarding Inner and Sub queries:
- A. Scalar subquery returns multiple values to outer query
-
Incorrect.
- C. Scalar Subqueries can be used anywhere single-valued expression is used: Select Where, and So on.
-
Correct!
- D. None of Above
-
Incorrect.
Correlated subqueries cannot be executed separately from the outer query because of:
- A. Performance Issues
-
Incorrect.
- B. Testing Complexity
-
Incorrect.
- C. Debugging Complexity
-
Incorrect.
- D. B and C
-
Correct!
Back To Top
Module 11
Using Table Expressions:
Which of the following statements best describe views?
- B. Views are defined with a single select statement
-
Incorrect.
- D. All of the above
-
Correct!
When flexibility of input is preferred, Table Valued Functions are more useful then views Because:
- A. They can accept input parameters
-
Correct!
- B. They occupy less space in memory
-
Incorrect.
- C. Both A and B
-
Incorrect.
- D. None of the above
-
Incorrect.
Choose all statements below which are correct about CTE (Common Table Expressions)?
- A. The Lifetime of CTE’s does not depend upon outer query
-
Incorrect.
- C. Like Derived Table, a CTE may not be referenced multiple times in the same query with one definition
-
Incorrect.
- D. All of the above.
-
Incorrect.
Back To Top
Module 12
Using Set Operators:
Your company have two databases: HR. Employees and Sales. Customers. You want to return Country, Region and city from both tables with the help of following Query:
SELECT country, region, city FROM HR. Employees
Answer
SELECT country, region, city FROM Sales. Customers;
Your main objective is to get city, region and country from both tables but, making sure Duplicate rows are eliminated. From the options below select the option that will eliminate duplicate rows and can be written between above two queries:
- A. UNION ALL
-
Incorrect.
- B. UNION
-
Correct!
- C. SUM () Function
-
Incorrect.
- D. None of the above
-
Incorrect.
Your company have two databases: Sales. Customers and Production. Suppliers. You want to get data for country and city, from both tables, with the help of following query:
SELECT country, city FROM SALES.CUSTOMERS
ANSWER
SELECT country, city FROM PRODUCTION.SUPPLIERS;
Your main objective is to get country and city from both tables which contains distinct records. Which of the following options from below can cater the requirements and can be written between the two queries:
Following statement contains queries about Joins and Apply Operators. Choose all those which are correct:
Back To Top
Module 13
Using Window Ranking, Offset and Aggregate Functions:
In SQL windowing operations, which of the following statements are false?
- A. Windows does not extend T-SQL’s set -based operations
-
Incorrect.
- B. Windows allow you to specify an order as part of a calculation, but considering order of input and final output
-
Incorrect
- C. Windows only allows framing of rows to support functions and does not allow partitioning.
-
Incorrect.
- D. All the above
-
Correct!.
Choose all the answers that best describes SQL windowing:
- A. A single Query can use multiple window functions
-
Correct!
- B. A single query can use multiple window functions but with only one over clause for multiple functions
-
Incorrect.
- D. All of the Above
-
Incorrect.
Which of the following queries are example of Window Offset function:
Back To Top
Module 14
Using Window Ranking, Offset and Aggregate Functions:
In the elements of Pivoting, there are 3 phases: Select the one which is not a phase:
- C. Aggregation performs an aggregation (such as Sum)
-
Incorrect.
- D. None of the above
-
Correct!.
We can use Group by with ROLLUP, CUBE and GROUPING SETS. Select the answer which best describes both.
- A. Cube provides shortcut for defining grouping sets, creates combinations assuming input columns form a hierarchy
-
Incorrect.
- D. None of the Above
-
Correct!
Back To Top
Module 15
Executing Stored Procedures
This question contains three parts. Choose all answers which are correct
- C. The correct syntax for executing stored procedure with a parameter is: EXEC Production.ProductsbySuppliers supplierID=1
-
Incorrect.
- D. A and B
-
Correct!.
Back To Top
Module 16
Programming with T-SQL
Which of the following Batch statements are valid:
- A. INSERT INTO dbo.table1 VALUES(1,2, N’abc’);
INSERT INTO dbo.table1 VALUES(2,5,N’def’);
GO -
Correct!.
- B. INSERT INTO dbo.table1 VALUE(5,6,N’abc’);
INSERT INTO dbo.table1 VALUES(3,2,N’def’);
GO -
Incorrect
- C. All the above
-
Incorrect.
- D. None of the above
-
Incorrect
Select all the answer that describes the error in the following T-SQL variables declaration and procedure execution :
Line 1:DECLARE Numrows INT=3, catid INT
Line 2:EXEC Production.ProdsByCategory
Line 3:@Numrows= numrows, @catid=catid
- B. Line 2 should be placed above Line 1.(Procedure should be executed first before variable declaration)
-
Correct!
- C. Line 3 have two errors : both Numrows should start with @symbol and same goes for catid
-
Incorrect.
- D. None of the Above
-
Incorrect.
You want to populate a table by creating 27 new rows. Before you create the rows, you need to check that the table exists. From the following T-SQL keywords, choose the one that you will NOT need to use.
Back To Top
Module 17
Implementing Error Handling
Following statements describes Error Handling in T-SQL . Choose all those which are not correct
- A. Try/Catch Blocks cannot be nested
-
Correct!
- B. Compile/Syntax errors and delayed name resolution errors cannot be caught by structured exception handling.
-
Incorrect
- C. We can use THROW outside of catch block with arguments that raise a user-defined error.
-
Incorrect.
- D. None of the above
-
Incorrect.
You have the following T-SQL script:
Line 1:BEGIN TRY
Line 2:INSERT INTO HumanResources.PossibleSkills(Skill Name, Category)
Line 3:VALUES ('Associate Consultant', 'IT Professional');
Line 4:END TRY
Line 5:DECLARE @prefix AS NVARCHAR(50) = 'There has been an error: ';
Line 6:BEGIN CATCH
Line 7:PRINT @prefix + ERROR_MESSAGE();
Line 8:THROW;
Line 9:END CATCH;
Line 10:GO
This code will not compile and execute. Select all the options that will execute and compile this code.
- A. At Line 8 : Throw should be removed
-
Incorrect.
- C. At Line 5 : declaration and assignment of @prefix variable should be moved below Line 6(within Catch Block)
-
Correct!
- D. None of the Above
-
Incorrect.
You are working on a project in which you are writing some error handling in a T-SQL script. If a problem arises you want to raise and error with a severity of 20. What option below will you choose to raise and error with 20 Severity.
Back To Top
Module 18
Implementing Transactions
Part 1: Which of the following statement/s about BEGIN TRANSACTION is/are not true?
- C. All the above
-
Incorrect.
- D. None of the above
-
Incorrect.
Part 2: Choose all the correct options which best describe COMMIT TRANSACTIONS.
- B. COMMIT ensures all the transaction’s modifications are made a permanent part of the database.
-
Incorrect.
- C. All the above
-
Correct!
- D. None of the above
-
Incorrect.
Part 3: Consider the following Transaction:
BEGIN TRY
BEGIN TRANSACTION
INSERT INTO dbo.SimpleOrders(custid, empid, orderdate)
VALUES (68,9,'2006-07-12');
INSERT INTO dbo.SimpleOrderDetails(orderid,productid,unitprice,qty)
VALUES (1, 2,15.20,20);
COMMIT TRANSACTION
END TRY
Should the above transaction be committed or rolled back ?
Part 4:ROLLBACK statement undoes all modifications made in the transaction by reverting the data to the state it was in at the beginning of the transaction. Which of the following is not true about ROLLBACK statement?
- A. Reverts all the rows inserted during the transaction
-
Incorrect.
- B. Delete all the rows inserted during the transaction
-
Incorrect.
- D. All the above.
-
Incorrect.
Part 5:Following statements are about Implementing Transactions in T-SQL. You have to decide which of them is correct. You can choose all, none, one or two correct answers:
- A. When the SET XACT_ABORT is ON, the entire transaction is terminated but does not roll back on an error.
-
Incorrect.
- B. The default setting of XACT_ABORT is ON
-
Incorrect.
- D. All the above.
-
Incorrect.
Consider the following Transaction below and select all those options that are correct.
LINE1:BEGIN TRY
Line 2: BEGIN TRANSACTION
Line 3: INSERT INTO SALES.ORDERS
Line 4: INSET INTO SALES.ORDERDETAILS
Line 5: COMMIT TRANSACTION
Line 6:END TRY
LINE 7:BEGIN CATCH
LINE 8: SELECT ERROR_NUMBER()
LINE 9: ROLLBACK TRANSACTION
LINE 8: END CATCH
Which of the following options are not correct about this transaction? :
- A. At LINE 3 insert will be successful
-
Incorrect.
- B. At LINE 4 insert will be successful
-
Incorrect.
- D. All the Above
-
Incorrect.
Select from the description below, what category of transaction does it falls into:
Individual data modification statements (for example, INSERT, UPDATE, and DELETE) submitted separately from other commands are automatically wrapped in a transaction by SQL Server. These single-statement transactions are automatically committed when the statement succeeds or are automatically rolled back when the statement encounters a runtime error.
- A. Auto commit Transactions
-
Correct!
- B. Explicit Transactions
-
Incorrect.
- C. Implicit Transactions
-
Incorrect.
- D. None of the above
-
Incorrect.
Back To Top
Tell Us About You:
- Home
- Practice Exam - Querying Data with Microsoft Transact-SQL
Practice Exam - Querying Data with Microsoft Transact-SQL
More Information:
- Learning Style: On Demand
- Learning Style: Practice Exam
- Difficulty: Beginner
- Course Duration: 1 Hour
- Course Info: Download PDF
- Certificate: See Sample
Contact a Learning Consultant
Need Training for 5 or More People?
Customized to your team's need:
- Annual Subscriptions
- Private Training
- Flexible Pricing
- Enterprise LMS
- Dedicated Customer Success Manager