Free Exam/Cram Practice Materials - Best Exam Practice Materials
Free Exam/Cram Practice Materials - Best Exam Practice Materials
NO.1 You administer a Microsoft SQL Server 2012 database named ContosoDb. Tables are defined as
shown in the exhibit. (Click the Exhibit button.)
You need to display rows from the Orders table for the Customers row having the CustomerId value
set to 1 in the following XML format.
2 from Freecram.net.
Get Latest & Valid 70-461 Exam's Question and Answers 1
https://www.freecram.net/exam/70-461-querying-microsoft-sql-server-2012-2014-e5198.html
Free Exam/Cram Practice Materials - Best Exam Practice Materials
IT Certification Guaranteed, The Easy Way!
NO.2 You develop a Microsoft SQL Server 2012 database that has two tables named SavingAccounts
and LoanAccounts. Both tables have a column named AccountNumber of the nvarchar data type.
You use a third table named Transactions that has columns named TransactionId AccountNumber,
Amount, and TransactionDate.
You need to ensure that when multiple records are inserted in the Transactions table, only the
records that have a valid AccountNumber in the SavingAccounts or LoanAccounts are inserted.
Which Transact-SQL statement should you use?
A. CREATE TRIGGER TrgValidateAccountNumber
ON Transactions
FOR INSERT
AS
BEGIN
IF EXISTS (
SELECT AccountNumber FROM inserted EXCEPT
(SELECT AccountNumber FROM LoanAccounts
UNION SELECT AccountNumber FROM SavingAccounts))
BEGIN
ROLLBACK TRAN
END
END
B. CREATE TRIGGER TrgValidateAccountNumber
3 from Freecram.net.
Get Latest & Valid 70-461 Exam's Question and Answers 2
https://www.freecram.net/exam/70-461-querying-microsoft-sql-server-2012-2014-e5198.html
Free Exam/Cram Practice Materials - Best Exam Practice Materials
IT Certification Guaranteed, The Easy Way!
ON Transactions
FOR INSERT
AS
BEGIN
INSERT INTO Transactions
SELECT TransactionID,AccountNumber,Amount,TransactionDate FROM inserted WHERE
AccountNumber IN (SELECT AccountNumber FROM LoanAccounts UNION SELECT AccountNumber
FROM SavingAccounts) END
C. CREATE TRIGGER TrgValidateAccountNumber
ON Transactions
INSTEAD OF INSERT
AS
BEGIN
INSERT INTO Transactions
SELECT TransactionID,AccountNumber,Amount,TransactionDate FROM inserted WHERE
AccountNumber IN (SELECT AccountNumber FROM LoanAccounts UNION SELECT AccountNumber
FROM SavingAccounts) END
D. CREATE TRIGGER TrgValidateAccountNumber
ON Transactions
INSTEAD OF INSERT
AS
BEGIN
IF EXISTS (
SELECT AccountNumber FROM inserted EXCEPT
(SELECT AccountNumber FROM LoanAccounts
UNION SELECT AccountNumber FROM SavingAccounts))
BEGIN
ROLLBACK TRAN
END
END
Answer: C
NO.3 You administer a Microsoft SQL Server database named Sales. The database is 3 terabytes in
size. The Sales database is configured as shown in the following table.
4 from Freecram.net.
Get Latest & Valid 70-461 Exam's Question and Answers 3
https://www.freecram.net/exam/70-461-querying-microsoft-sql-server-2012-2014-e5198.html
Free Exam/Cram Practice Materials - Best Exam Practice Materials
IT Certification Guaranteed, The Easy Way!
You discover that Sales_2.ndf is corrupt. You need to recover the corrupted data in the minimum
amount of time. What should you do?
A. Perform a filegroup restore.
B. Perform a transaction log restore.
C. Perform a file restore.
D. Perform a restore from a full backup.
Answer: C
NO.4 You develop a Microsoft SQL Server database for an order processing system that contains a
table named OrderCountSummary, as shown in the first exhibit. (Click the Exhibit tab.)
The table stores the names of vendors and the number of orders submitted by each vendor for each
food category: Dairy, Meat, Poultry, Seafood, and Vegetarian.
You need to generate a report that displays the total number of orders placed for each food category,
as shown in the following table.
5 from Freecram.net.
Get Latest & Valid 70-461 Exam's Question and Answers 4
https://www.freecram.net/exam/70-461-querying-microsoft-sql-server-2012-2014-e5198.html
Free Exam/Cram Practice Materials - Best Exam Practice Materials
IT Certification Guaranteed, The Easy Way!
Which four Transact-SQL segments should you use to develop the solution? To answer, move the
appropriate Transact-SQL segments from the list of Transact-SQL segments to the answer area and
arrange them in the correct order.
Answer:
6 from Freecram.net.
Get Latest & Valid 70-461 Exam's Question and Answers 5
https://www.freecram.net/exam/70-461-querying-microsoft-sql-server-2012-2014-e5198.html
Free Exam/Cram Practice Materials - Best Exam Practice Materials
IT Certification Guaranteed, The Easy Way!
Explanation:
You can use the PIVOT and UNPIVOT relational operators to change a table-valued expression into
another table. PIVOT rotates a table-valued expression by turning the unique values from one column
in the expression into multiple columns in the output, and performs aggregations where they are
required on any remaining column values that are wanted in the final output. UNPIVOT performs the
opposite operation to PIVOT by rotating columns of a table-valued expression into column values.
References:
https://docs.microsoft.com/en-us/sql/t-sql/queries/from-using-pivot-and-unpivot
NO.5 You create a stored procedure that will update multiple tables within a transaction.
You need to ensure that if the stored procedure raises a run-time error, the entire transaction is
terminated and rolled back.
Which Transact-SQL statement should you include at the beginning of the stored procedure?
7 from Freecram.net.
Get Latest & Valid 70-461 Exam's Question and Answers 6
https://www.freecram.net/exam/70-461-querying-microsoft-sql-server-2012-2014-e5198.html
Free Exam/Cram Practice Materials - Best Exam Practice Materials
IT Certification Guaranteed, The Easy Way!
A. SET XACT_ABORT ON
B. SET ARITHABORT OFF
C. TRY
D. SET ARITHABORT ON
E. BEGIN
F. SET XACT_ABORT OFF
Answer: A
Reference:
http://msdn.microsoft.com/en-us/library/ms190306.aspx
http://msdn.microsoft.com/en-us/library/ms188792.aspx
NO.6 You create a table that has the StudentCode, SubjectCode, and Marks columns to record mid-
year marks for students. The table has marks obtained by 50 students for various subjects.
You need to ensure that the following requirements are met:
* Students must be ranked based on their average marks.
* If one or more students have the same average, the same rank must be given to these students.
* Consecutive ranks must be skipped when the same rank is assigned.
Which Transact-SQL query should you use?
A. SELECT Id, Name, Marks,
DENSE_RANK() OVER(ORDER BY Marks DESC) AS Rank
FROM StudentMarks
B. SELECT StudentCode as Code,
NTILE(2) OVER(ORDER BY AVG (Marks) DESC) AS Value
FROM StudentMarks
GROUP BY StudentCode
C. SELECT StudentCode AS Code,Marks AS Value FROM (
SELECT StudentCode, Marks AS Marks,
RANK() OVER(PARTITION BY SubjectCode ORDER BY Marks ASC) AS Rank
FROM StudentMarks) tmp
WHERE Rank = 1
D. SELECT StudentCode as Code,
RANK() OVER(ORDER BY AVG (Marks) DESC) AS Value
FROM StudentMarks
GROUP BY StudentCode
E. SELECT StudentCode AS Code,Marks AS Value FROM (
SELECT StudentCode, Marks AS Marks,
RANK() OVER(PARTITION BY SubjectCode ORDER BY Marks DESC) AS Rank
FROM StudentMarks) tmp
WHERE Rank = 1
F. SELECT StudentCode AS Code,Marks AS Value FROM (
SELECT StudentCode, Marks AS Marks,
RANXO OVER(PARTITION BY StudentCode ORDER BY Marks DESC) AS Rank
FROM StudentMarks) tmp
WHERE Rank = 1
G. SELECT StudentCode as Code,
8 from Freecram.net.
Get Latest & Valid 70-461 Exam's Question and Answers 7
https://www.freecram.net/exam/70-461-querying-microsoft-sql-server-2012-2014-e5198.html
Free Exam/Cram Practice Materials - Best Exam Practice Materials
IT Certification Guaranteed, The Easy Way!
NO.7 You administer a Microsoft SQL Server instance that will support several databases.
You need to ensure that every new database created has a data type named postalcode that contains
the same attributes.
What should you do?
A. Create a user-defined data type on the master database.
B. Create a user-defined type on the model database.
C. Create a user-defined type on the master database.
D. Create a user-defined data type on the model database.
Answer: D
Explanation:
One option is to create SQL Server user defined data types.
One trick with new databases is to create the objects in the model database, so as new databases are
created the user defined data types will automatically be available.
References: https://www.mssqltips.com/sqlservertip/1628/sql-server-user-defined-data-types-rules-
and-defaults/
NO.8 You need to create a query that meets the following requirements:
* The query must return a list of salespeople ranked by amount of sales and organized by postal
code.
* The salesperson who has the highest amount of sales must be ranked first.
Part of the correct Transact-SQL has been provided in the answer area below. Enter the code in the
answer area that resolves the problem and meets the stated goals or requirements. You can add
code within code that has been provided as well as below it.
9 from Freecram.net.
Get Latest & Valid 70-461 Exam's Question and Answers 8
https://www.freecram.net/exam/70-461-querying-microsoft-sql-server-2012-2014-e5198.html
Free Exam/Cram Practice Materials - Best Exam Practice Materials
IT Certification Guaranteed, The Easy Way!
Use the 'Check Syntax' button to verify your work. Any syntax or spelling errors will be reported by
line and character position.
A. 1 SELECT RowNumber() OVER(PARTITION BY PostalCode ORDER BY SalesYTd DESC) AS "Ranking",
2 p.LastName, s.SalesYTD, a.PostalCode
3 FROM Sales.SalesPerson AS a
etc
10 from Freecram.net.
Get Latest & Valid 70-461 Exam's Question and Answers 9
https://www.freecram.net/exam/70-461-querying-microsoft-sql-server-2012-2014-e5198.html
Free Exam/Cram Practice Materials - Best Exam Practice Materials
IT Certification Guaranteed, The Easy Way!
11 from Freecram.net.
Get Latest & Valid 70-461 Exam's Question and Answers 10
https://www.freecram.net/exam/70-461-querying-microsoft-sql-server-2012-2014-e5198.html
Free Exam/Cram Practice Materials - Best Exam Practice Materials
IT Certification Guaranteed, The Easy Way!
NO.9 You use Microsoft SQL Server 2012 database to develop a shopping cart application.
You need to invoke a table-valued function for each row returned by a query.
Which Transact-SQL operator should you use?
A. PIVOT
B. UNPIVOT
C. CROSS APPLY
D. CROSS JOIN
Answer: C
Reference:
http://msdn.microsoft.com/en-us/library/ms175156.aspx
NO.10 You administer a Microsoft SQL Server database that supports a banking transaction
management application.
You need to retrieve a list of account holders who live in cities that do not have a branch location.
Which Transact-SQL query or queries should you use? (Each correct answer presents a complete
solution. Choose all that apply.)
A. SELECT AccountHolderID
FROM AccountHolder
WHERE CityID <> SOME (SELECT CityID FROM BranchMaster)
B. SELECT AccountHolderID
FROM AccountHolder
WHERE CityID <> ALL (SELECT CityID FROM BranchMaster)
C. SELECT AccountHolderID
FROM AccountHolder
WHERE CityID <> ANY (SELECT CityID FROM BranchMaster)
D. SELECT AccountHolderID
FROM AccountHolder
WHERE CityID NOT IN (SELECT CityID FROM BranchMaster)
Answer: B,D
Explanation:
Verified the answers as correct.
NO.11 Your database contains a table named Purchases. The table includes a DATETIME column
named PurchaseTime that stores the date and time each purchase is made. There is a non-clustered
index on the PurchaseTime column.
The business team wants a report that displays the total number of purchases made on the current
day.
12 from Freecram.net.
Get Latest & Valid 70-461 Exam's Question and Answers 11
https://www.freecram.net/exam/70-461-querying-microsoft-sql-server-2012-2014-e5198.html
Free Exam/Cram Practice Materials - Best Exam Practice Materials
IT Certification Guaranteed, The Easy Way!
You need to write a query that will return the correct results in the most efficient manner.
Which Transact-SQL query should you use?
A. SELECT COUNT(*)
FROM Purchases
WHERE PurchaseTime = GETDATE()
B. SELECT COUNT(*)
FROM Purchases
WHERE PurchaseTime >= CONVERT(DATE, GETDATE())
AND PurchaseTime < DATEADD(DAY, 1, CONVERT(DATE, GETDATE()))
C. SELECT COUNT(*)
FROM Purchases
WHERE CONVERT(VARCHAR, PurchaseTime, 112) = CONVERT(VARCHAR, GETDATE(), 112)
D. SELECT COUNT(*)
FROM Purchases
WHERE PurchaseTime = CONVERT(DATE, GETDATE())
Answer: B
Explanation:
Two answers will return the correct results (the "WHERE CONVERT..." and "WHERE ... AND ... "
answers).
The correct answer for Microsoft would be the answer that is most "efficient". Anybody have a clue
as to which is most efficient? In the execution plan, the one that I've selected as the correct answer is
the query with the shortest duration. Also, the query answer with "WHERE CONVERT..." threw
warnings in the execution plan...something about affecting CardinalityEstimate and SeekPlan.
I also found this article, which leads me to believe that I have the correct answer:
http://technet.microsoft.com/en-us/library/ms181034.aspx
NO.12 You administer a Microsoft SQL Server 2012 database named ContosoDb. Tables are defined
as shown in the exhibit. (Click the Exhibit button.)
You need to display rows from the Orders table for the Customers row having the CustomerId value
set to 1 in the following XML format:
<row OrderId="1" OrderDate="2000-01-01T00:00:00" Amount="3400.00" Name="Customer A"
Country="Australia" />
<row OrderId="2" OrderDate="2001-01-01T00:00:00" Amount="4300.00" Name="Customer A"
Country="Australia" /> Which Transact-SQL query should you use?
A. SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId WHERE
13 from Freecram.net.
Get Latest & Valid 70-461 Exam's Question and Answers 12
https://www.freecram.net/exam/70-461-querying-microsoft-sql-server-2012-2014-e5198.html
Free Exam/Cram Practice Materials - Best Exam Practice Materials
IT Certification Guaranteed, The Easy Way!
NO.13 You are the administrator for a heavily-used OLTP Microsoft SQL Server database.
You are troubleshooting performance issues seen when using stored procedures in the database. The
database stores millions of orders across thousands of customers. Some of the customers have large
numbers of orders, while others have only one order. You update the statistics and perform
defragmentation of all tables and indexes, but two stored procedures still have issues when accessing
data.
p_GetCustomer accepts @companyID as a parameter. From the results of profiling, you know that 90
percent of the calls use the @companyid value of 5, while the other 10 percent of calls are evenly
distributed across another 10000 values. While viewing the execution plan, you discover that a non-
clustered index seek is used.
p_GetShipDate accepts @orderID as a parameter and returns the ship date for that order. You
discover that the execution plan is performing a scan on a non-clustered index that has orderID as the
index key.
You need to add appropriate query hints to each stored procedure to improve the performance.
What should you do? To answer, drag the appropriate procedures to the correct hints. Each
procedure may be used once, more than once, or not at all. You may need to drag the split bar
between panes or scroll to view content.
14 from Freecram.net.
Get Latest & Valid 70-461 Exam's Question and Answers 13
https://www.freecram.net/exam/70-461-querying-microsoft-sql-server-2012-2014-e5198.html
Free Exam/Cram Practice Materials - Best Exam Practice Materials
IT Certification Guaranteed, The Easy Way!
Answer:
Explanation:
Box 1: Optimize FOR..
OPTIMIZE FOR ( @variable_name { UNKNOWN | = literal_constant } [ , ...n ] ) Instructs the query
optimizer to use a particular value for a local variable when the query is compiled and optimized. The
value is used only during query optimization, and not during query execution.
Box 2: FORCESEEK
FORCESEEK [ (index_value(index_column_name [ ,... n ] )) ]
Specifies that the query optimizer use only an index seek operation as the access path to the data in
the table or view.
References:
https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-query?view=sql-server-2017
https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-table?view=sql-server-2017
15 from Freecram.net.
Get Latest & Valid 70-461 Exam's Question and Answers 14
https://www.freecram.net/exam/70-461-querying-microsoft-sql-server-2012-2014-e5198.html
Free Exam/Cram Practice Materials - Best Exam Practice Materials
IT Certification Guaranteed, The Easy Way!
Answer:
DECLARE @invoice XML(Sales.InvoiceSchema)
NO.15 You have a database that contains the tables shown in the exhibit. (Click the Exhibit button.)
You need to create a view named uv_CustomerFullName to meet the following requirements:
* The code must NOT include object delimiters.
* The view must be created in the Sales schema.
* Columns must only be referenced by using one-part names.
16 from Freecram.net.
Get Latest & Valid 70-461 Exam's Question and Answers 15
https://www.freecram.net/exam/70-461-querying-microsoft-sql-server-2012-2014-e5198.html
Free Exam/Cram Practice Materials - Best Exam Practice Materials
IT Certification Guaranteed, The Easy Way!
* The view must return the first name and the last name of all customers.
* The view must prevent the underlying structure of the customer table from being changed.
* The view must be able to resolve all referenced objects, regardless of the user's default schema.
Which code segment should you use?
To answer, type the correct code in the answer area.
A. CREATE VIEW Sales.uv_CustomerFullName
WITH SCHEMABINDING
AS
SELECT FirstName, LastName
B. CREATE VIEW Sales.uv_CustomerFullName
WITH SCHEMABINDING
AS
SELECT FirstName, LastName
FROM Sales.Customers
Answer: B
Reference:
http://msdn.microsoft.com/en-us/library/ms187956.aspx
NO.16 You administer several Microsoft SQL Server 2012 database servers. Merge replication has
been configured for an application that is distributed across offices throughout a wide area network
(WAN). Many of the tables involved in replication use the XML and varchar (max) data types.
Occasionally, merge replication fails due to timeout errors. You need to reduce the occurrence of
these timeout errors. What should you do?
A. Set the Merge agent on the problem subscribers to use the slow link agent profile.
B. Create a snapshot publication, and reconfigure the problem subscribers to use the snapshot
publication.
C. Set the Remote Connection Timeout on the Publisher to 0.
D. Change the Merge agent on the problem subscribers to run continuously.
Answer: A
NO.17 You have a database that contains the tables shown in the exhibit. (Click the Exhibit button.)
17 from Freecram.net.
Get Latest & Valid 70-461 Exam's Question and Answers 16
https://www.freecram.net/exam/70-461-querying-microsoft-sql-server-2012-2014-e5198.html
Free Exam/Cram Practice Materials - Best Exam Practice Materials
IT Certification Guaranteed, The Easy Way!
You have an application named Appl. You have a parameter named @Count that uses the int data
type. App1 is configured to pass @Count to a stored procedure. You need to create a stored
procedure named usp_Customers for Appl. Usp_Customers must meet the following requirements:
* NOT use object delimiters.
* Minimize sorting and counting.
* Return only the last name of each customer in alphabetical order.
* Return only the number of rows specified by the @Count parameter.
* The solution must NOT use BEGIN and END statements.
18 from Freecram.net.
Get Latest & Valid 70-461 Exam's Question and Answers 17
https://www.freecram.net/exam/70-461-querying-microsoft-sql-server-2012-2014-e5198.html
Free Exam/Cram Practice Materials - Best Exam Practice Materials
IT Certification Guaranteed, The Easy Way!
NO.18 You use Microsoft SQL Server 2012 to develop a database application.
You create a table by using the following definition:
CREATE TABLE Prices (
PriceId int IDENTITY(1,1) PRIMARY KEY,
ActualPrice NUMERIC(16,9),
PredictedPrice NUMERIC(16,9)
)
You need to create a computed column based on a user-defined function named udf_price_index.
You also need to ensure that the column supports an index.
Which three Transact-SQL statements should you use? (To answer, move the appropriate SQL
statements from the list of statements to the answer area and arrange them in the correct order.)
19 from Freecram.net.
Get Latest & Valid 70-461 Exam's Question and Answers 18
https://www.freecram.net/exam/70-461-querying-microsoft-sql-server-2012-2014-e5198.html
Free Exam/Cram Practice Materials - Best Exam Practice Materials
IT Certification Guaranteed, The Easy Way!
Answer:
20 from Freecram.net.
Get Latest & Valid 70-461 Exam's Question and Answers 19
https://www.freecram.net/exam/70-461-querying-microsoft-sql-server-2012-2014-e5198.html
Free Exam/Cram Practice Materials - Best Exam Practice Materials
IT Certification Guaranteed, The Easy Way!
21 from Freecram.net.
Get Latest & Valid 70-461 Exam's Question and Answers 20
https://www.freecram.net/exam/70-461-querying-microsoft-sql-server-2012-2014-e5198.html