Download Querying Microsoft SQL Server 2012-2014.70-461.SelfTestEngine.2018-09-19.130q.vcex

Vendor: Microsoft
Exam Code: 70-461
Exam Name: Querying Microsoft SQL Server 2012/2014
Date: Sep 19, 2018
File Size: 12 MB

How to open VCEX files?

Files with VCEX extension can be opened by ProfExam Simulator.

ProfExam Discount

Demo Questions

Question 1
A table named Profits stores the total profit made each year within a territory. The Profits table has columns named Territory, Year, and Profit. 
You need to create a report that displays the profits made by each territory for each year and its previous year. 
Which Transact-SQL query should you use? 
  1. SELECT Territory, Year, Profit,
    LEAD(Profit, 1, 0) OVER (PARTITION BY Territory ORDER BY Year) 
    AS PrevProfit 
    FROM Profits 
  2. SELECT Territory, Year, Profit,
    LAG(Profit, 1, 0) OVER (PARTITION BY Year ORDER BY Territory) 
    AS PrevProfit 
    FROM Profits 
  3. SELECT Territory, Year, Profit,
    LAG(Profit, 1, 0) OVER (PARTITION BY Territory ORDER BY Year) 
    AS PrevProfit 
    FROM Profits 
  4. SELECT Territory, Year, Profit,
    LEAD(Profit, 1, 0) OVER (PARTITION BY Year ORDER BY Territory) 
    AS PrevProfit 
    FROM Profits
Correct answer: C
Explanation:
LAG accesses data from a previousrow in the same result set without the use of a self-join in SQL Server 2016. LAG provides access to a row at a given physical offset that comes before the current row. Use this analytic function in a SELECT statement to compare values in the current row with values in a previous row. Use ORDER BY Year, not ORDER BY Territory. Example: The following example uses the LAG function to return the difference in sales quotas for a specific employee over previous years. Notice that because there is no lag valueavailable for the first row, the default of zero (0) is returned.USE AdventureWorks2012; GO SELECT BusinessEntityID, YEAR(QuotaDate) AS SalesYear, SalesQuota AS CurrentQuota,    LAG(SalesQuota, 1,0) OVER (ORDER BY YEAR(QuotaDate)) AS PreviousQuota FROM Sales.SalesPersonQuotaHistory WHERE BusinessEntityID = 275 and YEAR(QuotaDate) IN ('2005','2006'); Incorrect Answers:A, D: LEAD accesses data from a subsequent row in the same result set without the use of a self-join in SQL Server 2016. LEAD provides access to a row at a given physical offset that follows the current row. Use this analytic function in a SELECT statement to compare values in the current row with values in a following row.B: Use ORDER BY Year, not ORDER BY Territory.References: https://msdn.microsoft.com/en-us/library/hh231256.aspx
LAG accesses data from a previousrow in the same result set without the use of a self-join in SQL Server 2016. LAG provides access to a row at a given physical offset that comes before the current row. Use this analytic function in a SELECT statement to compare values in the current row with values in a previous row. 
Use ORDER BY Year, not ORDER BY Territory. 
Example: The following example uses the LAG function to return the difference in sales quotas for a specific employee over previous years. Notice that because there is no lag valueavailable for the first row, the default of zero (0) is returned.
USE AdventureWorks2012; 
GO 
SELECT BusinessEntityID, YEAR(QuotaDate) AS SalesYear, SalesQuota AS CurrentQuota, 
   LAG(SalesQuota, 1,0) OVER (ORDER BY YEAR(QuotaDate)) AS PreviousQuota 
FROM Sales.SalesPersonQuotaHistory 
WHERE BusinessEntityID = 275 and YEAR(QuotaDate) IN ('2005','2006'); 
Incorrect Answers:
A, D: LEAD accesses data from a subsequent row in the same result set without the use of a self-join in SQL Server 2016. LEAD provides access to a row at a given physical offset that follows the current row. Use this analytic function in a SELECT statement to compare values in the current row with values in a following row.
B: Use ORDER BY Year, not ORDER BY Territory.
References: https://msdn.microsoft.com/en-us/library/hh231256.aspx
Question 2
You use Microsoft SQL Server 2012 database to develop a shopping cart application. 
You need to rotate the unique values of the ProductName field of a table-valued expression into multiple columns in the output. 
Which Transact-SQL operator should you use?
  1. CROSS JOIN
  2. CROSS APPLY
  3. PIVOT
  4. UNPIVOT
Correct answer: C
Explanation:
http://technet.microsoft.com/en-us/library/ms177634.aspx
http://technet.microsoft.com/en-us/library/ms177634.aspx
Question 3
You administer a Microsoft SQL Server database that supports a shopping application. 
You need to retrieve a list of customers who live in territories that do not have a sales person. 
Which Transact- SQL query or queries should you use? (Each correct answer presents a complete solution. Choose all that apply.)
  1. SELECT CustomerID FROM Customer 
    WHERE TerritoryID <> SOME(SELECT TerritoryID FROM Salesperson)
  2. SELECT CustomerID FROM Customer 
    WHERE TerritoryID <> ALL(SELECT TerritoryID FROM Salesperson)
  3. SELECT CustomerID FROM Customer 
    WHERE TerritoryID <> ANY(SELECT TerritoryID FROM Salesperson)
  4. SELECT CustomerID FROMCustomer 
    WHERE TerritoryID NOT IN(SELECT TerritoryID FROM Salesperson)
Correct answer: BD
Question 4
You support a database structure shown in the exhibit.
  
You need to write a query that displays the following details:
  • Total sales made by sales people, year, city, and country 
  • Sub totals only at the city level and country level 
  • A grand total of the sales amount 
Which Transact-SQL query should you use? 
  1. SELECT SalesPerson.Name, Country, City,
    DatePart(yyyy, SaleDate) AS Year, Sum(Amount) AS Total 
    FROM Sale INNER JOIN SalesPerson 
    ON Sale.SalesPersonID = SalesPerson.SalesPersonID 
    GROUP BY GROUPING SETS((SalesPerson.Name, Country, City, 
    DatePart(yyyy, SaleDate)), (Country, City), (Country), ())
  2. SELECT SalesPerson.Name, Country, City, 
    DatePart(yyyy, SaleDate) AS Year, Sum(Amount) AS Total 
    FROM Sale INNER JOIN SalesPerson 
    ON Sale.SalesPersonID = SalesPerson.SalesPersonID 
    GROUP BY CUBE(SalesPerson.Name, Country, City, DatePart(yyyy, SaleDate)) 
  3. SELECT SalesPerson.Name, Country, City,
    DatePart(yyyy, SaleDate) AS Year, Sum(Amount) AS Total 
    FROM Sale INNER JOIN SalesPerson 
    ON Sale.SalesPersonID = SalesPerson.SalesPersonID 
    GROUP BY CUBE(SalesPerson.Name, DatePart(yyyy, SaleDate), City, Country) 
  4. SELECT SalesPerson.Name, Country, City,
    DatePart(yyyy, SaleDate) AS Year, Sum(Amount) AS Total 
    FROM Sale INNER JOIN SalesPerson 
    ON Sale.SalesPersonID = SalesPerson.SalesPersonID 
    GROUP BY ROLLUP(SalesPerson.Name, DatePart(yyyy, SaleDate), City, 
    Country)
Correct answer: A
Explanation:
Be careful with this question, because on exam can be different options for answer. Reference: http://www.grapefruitmoon.net/diving-into-t-sql-grouping-sets/Reference: http://msdn.microsoft.com/en-us/library/ms177673.aspx
Be careful with this question, because on exam can be different options for answer. 
Reference: http://www.grapefruitmoon.net/diving-into-t-sql-grouping-sets/
Reference: http://msdn.microsoft.com/en-us/library/ms177673.aspx
Question 5
You are developing a database that will contain price information. 
You need to store the prices that include a fixed precision and a scale of six digits. 
Which data type should you use?
  1. Float
  2. Money
  3. Small money
  4. Numeric
Correct answer: D
Explanation:
Numeric is the only one in the list that can give a fixed precision and scale. Reference: http://msdn.microsoft.com/en-us/library/ms179882.aspx
Numeric is the only one in the list that can give a fixed precision and scale. 
Reference: http://msdn.microsoft.com/en-us/library/ms179882.aspx
Question 6
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.) 
  1. SELECT AccountHolderID
    FROM AccountHolder 
    WHERE CityID NOT IN (SELECT CityID FROM BranchMaster) 
  2. SELECT AccountHolderID
    FROM AccountHolder 
    WHERE CityID <> ALL (SELECT CityID FROM BranchMaster) 
  3. SELECT AccountHolderID
    FROM AccountHolder 
    WHERE CityID <> SOME (SELECT CityID FROM BranchMaster) 
  4. SELECT AccountHolderID
    FROM AccountHolder 
    WHERE CityID <> ANY (SELECT CityID FROM BranchMaster)
Correct answer: AB
Explanation:
Reference: http://msdn.microsoft.com/en-us/library/ms188047.aspxReference: http://msdn.microsoft.com/en-us/library/ms177682.aspxReference: http://msdn.microsoft.com/en-us/library/ms173545.aspx
Reference: http://msdn.microsoft.com/en-us/library/ms188047.aspx
Reference: http://msdn.microsoft.com/en-us/library/ms177682.aspx
Reference: http://msdn.microsoft.com/en-us/library/ms173545.aspx
Question 7
Note: This question is part of a series of questions that use the same set of answer choices. An answer choice may be correct for more than one question in the series.
You administer a Microsoft SQL Server database. The database contains a table named Employee. Part of the Employee table is shown in the exhibit. (Click the Exhibit button.) 
  
  
Unless stated above, no columns in the Employee table reference other tables. 
Confidential information about the employees is stored in a separate table named EmployeeData. One record exists within EmployeeData for each record in the Employee table. 
You need to assign the appropriate constraints and table properties to ensure data integrity and visibility. 
On which column in the Employee table should you create a unique constraint?
  1. DateHired
  2. DepartmentID
  3. EmployeeID
  4. EmployeeNum
  5. FirstName
  6. JobTitle
  7. LastName
  8. MiddleName
  9. ReportsToID
Correct answer: D
Question 8
You administer a Microsoft SQL Server database. The database contains a table named Employee. Part of the Employee table is shown in the exhibit. (Click the Exhibit button.) 
  
  
Unless stated above, no columns in the Employee table reference other tables. 
Confidential information about the employees is stored in a separate table named EmployeeData. One record exists within EmployeeData for each record in the Employee table. 
You need to assign the appropriate constraints and table properties to ensure data integrity and visibility. 
On which column in the Employee table should you use an identity specification to include a seed of 1,000 and an increment of 1?
  1. DateHired
  2. DepartmentID
  3. EmployeeID
  4. EmployeeNum
  5. FirstName
  6. JobTitle
  7. LastName
  8. MiddleName
  9. ReportsToID
Correct answer: C
Question 9
You administer a Microsoft SQL Server database that includes a table named Products. The Products table has columns named ProductId, ProductName, and CreatedDateTime. 
The table contains a unique constraint on the combination of ProductName and CreatedDateTime. 
You need to modify the Products table to meet the following requirements:
  • Remove all duplicates of the Products table based on the ProductName column. 
  • Retain only the newest Products row. 
Which Transact-SQL query should you use? 
  1.   WITH CTEDupRecords
    AS 
      ( 
        SELECT MIN(CreatedDateTime) AS CreatedDateTime, ProductName 
        FROM Products 
        GROUP BY ProductName 
        HAVING COUNT(*) > 1 
      ) 
      DELETE p 
      FROM Products p 
      JOIN CTEDupRecords cte ON cte.ProductName = p.ProductName 
      AND cte.CreatedDateTime >  p.CreatedDateTime 
  2.   WITH CTEDupRecords
    AS 
      ( 
        SELECT MIN(CreatedDateTime) AS CreatedDateTime, ProductName 
        FROM Products 
        GROUP BY ProductName 
        HAVING COUNT(*) > 1 
      ) 
      DELETE p 
      FROM Products p 
      JOIN CTEDupRecords cte ON p.ProductName = cte.ProductName 
      AND p.CreatedDateTime > cte.CreatedDateTime 
  3.   WITH CTEDupRecords
    AS 
      ( 
        SELECT MIN(CreatedDateTime) AS CreatedDateTime, ProductName 
        FROM Products 
        GROUP BY ProductName 
      ) 
      DELETE p 
      FROM Products p 
      JOIN CTEDupRecords cte ON p.ProductName = cte.ProductName 
  4.   WITH CTEDupRecords
    AS 
      ( 
        SELECT MAX(CreatedDateTime) AS CreatedDateTime, ProductName 
        FROM Products 
        GROUP BY ProductName 
        HAVING COUNT(*) > 1 
      ) 
      DELETE Products 
      FROM Products p 
      JOIN CTEDupRecords cte ON p.ProductName = cte.ProductName
Correct answer: B
Question 10
You develop three Microsoft SQL Server databases named Database1, Database2, and Database3. You have permissions on both Database1 and Database2. 
You plan to write and deploy a stored procedure named dbo.usp_InsertEvent in Database3.dbo.usp_InsertEvent must execute other stored procedures in the other databases. 
You need to ensure that callers that do not have permissions on Database1 or Database2 can execute the stored procedure. 
Which Transact-SQL statement should you use?
  1. USE Database2
  2. EXECUTE AS OWNER
  3. USE Database1
  4. EXECUTE AS CALLER
Correct answer: B
Explanation:
Reference: http://msdn.microsoft.com/en-us/library/ms188354.aspxReference: http://blog.sqlauthority.com/2007/10/06/sql-server-executing-remote-stored-procedure-callingstored-procedure-on-linked-server/
Reference: http://msdn.microsoft.com/en-us/library/ms188354.aspx
Reference: http://blog.sqlauthority.com/2007/10/06/sql-server-executing-remote-stored-procedure-callingstored-procedure-on-linked-server/
HOW TO OPEN VCE FILES

Use VCE Exam Simulator to open VCE files
Avanaset

HOW TO OPEN VCEX AND EXAM FILES

Use ProfExam Simulator to open VCEX and EXAM files
ProfExam Screen

ProfExam
ProfExam at a 20% markdown

You have the opportunity to purchase ProfExam at a 20% reduced price

Get Now!