exam questions

Exam 70-762 All Questions

View all questions & answers for the 70-762 exam

Exam 70-762 topic 1 question 22 discussion

Actual exam question from Microsoft's 70-762
Question #: 22
Topic #: 1
[All 70-762 Questions]

DRAG DROP -
Note: This question is part of a series of questions that use the same scenario. For your convenience, the scenario is repeated in each question. Each question presents a different goal and answer choices, but the text of the scenario is exactly the same in each question in this series.
You have a database named DB1 that contains the following tables: Customer, CustomerToAccountBridge, and CustomerDetails. The three tables are part of the
Sales schema. The database also contains a schema named Website. You create the Customer table by running the following Transact-SQL statement:

The value of the CustomerStatus column is equal to one for active customers. The value of the Account1Status and Account2Status columns are equal to one for active accounts. The following table displays selected columns and rows from the Customer table.

You plan to create a view named Website.Customer and a view named Sales.FemaleCustomers.
Website.Customer must meet the following requirements:
1. Allow users access to the CustomerName and CustomerNumber columns for active customers.
2. Allow changes to the columns that the view references. Modified data must be visible through the view.
3. Prevent the view from being published as part of Microsoft SQL Server replication.
Sales.Female.Customers must meet the following requirements:
1. Allow users access to the CustomerName, Address, City, State and PostalCode columns.
2. Prevent changes to the columns that the view references.
3. Only allow updates through the views that adhere to the view filter.
You have the following stored procedures: spDeleteCustAcctRelationship and spUpdateCustomerSummary. The spUpdateCustomerSummary stored procedure was created by running the following Transacr-SQL statement:

The following table displays a selected columns and rows from the Customer table. Thr value of the CustomerStatus column is equal to one for active customers.
The value of the Account1Status and Account2Status columns are equal to one for active accounts.
You run the spUpdateCustomerSummary stored procedure to make changes to customer account summaries. Other stored procedures call the spDeleteCustAcctRelationship to delete records from the CustomerToAccountBridge table.
Users report that the following SELECT statement statement takes a long time to complete:

You need to create an index that meets the following requirements:
1. Improve the performance of the SELECT statement.
2. requires minimum index key size.
3. Only contains active customers.
4. Makes no change to the existing primary key.
5. Contains all of the columns required by the SELECT statement.
Which three Transact_SQL segments should you use to develop the solution? To answer, move the appropriate code blocks from the list of code blocks to the answer area and arrange them in the correct order.
Select and Place:

Show Suggested Answer Hide Answer
Suggested Answer:
Box 1: Clustered Index -
With the same size of keys, the nonclustered indexes need more space than clustered indexes.
Box 2, Box 3:
Include the CustomerStatus column in the index, and only when CustomerStatusnot equal to 1 (the active customers).
References:
http://www.sqlserverlogexplorer.com/overview-of-cluster-and-noncluster-index/

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
NickMane
Highly Voted 5 years, 2 months ago
And the correct answer is: --4. Makes no change to the existing primary key. CREATE NONCLUSTERED INDEX IX_Customer_CreatedDate --5. Contains all of the columns required by the SELECT statement. ON CUSTOMER(CreatedDate) INCLUDE(Segment, Country-code, PhoneNumber) --3. Only contains active customers. WHERE CustomerStatus = 1
upvoted 62 times
Anette
4 years, 10 months ago
Why clustered index? The new maximum key size for nonclustered indexes is 1700 bytes. The maximum key size for clustered indexes remains 900 bytes.
upvoted 1 times
Anette
4 years, 10 months ago
I mean why not clustered? I think its clustered index. Also non-clustered indexes are slower than clustered indexes.
upvoted 1 times
Anette
4 years, 10 months ago
Also, the default index is clustered so there is not need to make any change to the existing primary key.
upvoted 2 times
mrn0107
4 years, 10 months ago
YOu can have only 1 clustered index per table. You have a primary key , that is unique clustered index, so you can not have another one.
upvoted 4 times
ZSQL
4 years, 6 months ago
when you create a clustered index on a table that already has a by default clustered index for Pk, SQL server will automatically changes the pk column to non clustered index .
upvoted 2 times
...
...
...
...
...
TheDUdeu
4 years, 4 months ago
This is correct the Select fields go in the Include.
upvoted 1 times
...
...
ClydeZ
Highly Voted 5 years, 4 months ago
"CustomerStatus column is equal to one for active customers", why set "CustomerStatus <> 1" to find "only active" Customers? shouldn't it be "CustomerStatus = 1"
upvoted 27 times
...
jaysun
Most Recent 4 years, 4 months ago
you can't have more than one clustered index on a table , so it should be nonclustered index with customerstatus = 1
upvoted 2 times
...
alvmarcoux
4 years, 4 months ago
Like NikeMane said, but also it has to inlcude CustomerNumber: CREATE NONCLUSTERED INDEX IX_Customer_CreatedDate ON CUSTOMER(CreatedDate) INCLUDE(Segment, Country-code, PhoneNumber,CustomerNumber) WHERE CustomerStatus = 1
upvoted 1 times
...
TheDUdeu
4 years, 5 months ago
Customer table already has a primary key and a clustered index which there is only one on each table. So it has to be a nonclustered index as the right answer.
upvoted 1 times
...
Luzix
4 years, 5 months ago
3. Only contains active customers. --> SO the only way to do it, is filtering the index by CustomerStatus = 1
upvoted 1 times
...
Andy7622
4 years, 7 months ago
I think there's a mistake in the 'WHERE CustomerID =1' statement. It should be 'CustomerStatus' instead of ' CustomerID'.
upvoted 4 times
...
smartrammy
4 years, 7 months ago
Customer table already has Primay key Clustered. So table can have only one Clustered index, so in this case it has to be Non - Clustered Index -CREATE NONCLUSTERED INDEX IX_Customer_CreatedDate
upvoted 4 times
...
strikersree
4 years, 10 months ago
4, 5, 1(customer_status =1)
upvoted 2 times
...
Bartek
5 years, 2 months ago
Tellence is right. If we put bigger key then query needs to read more data pages and query is slowler than we want. According exercise we need to choose "2. requires minimum index key size." See example code and look on Actual Execution plan after executing it. CREATE TABLE [dbo].[TEST]( [ACCOUNTNUMBER] [int] NULL, [BALANCE] [int] NULL, [PRODUCTCODE] [varchar](50) NULL ) DECLARE @COUNTER INT = 1, @COUNTERMAX INT = 10000 WHILE @COUNTER <= @COUNTERMAX BEGIN INSERT INTO dbo.TEST VALUES (@COUNTER,@COUNTER+10, 'TEST' ) SET @COUNTER = @COUNTER + 1 END CREATE NONCLUSTERED INDEX NCI ON DBO.TEST (PRODUCTCODE) INCLUDE (ACCOUNTNUMBER) WHERE BALANCE > 5000 SET STATISTICS IO ON SELECT PRODUCTCODE FROM dbo.TEST WHERE ACCOUNTNUMBER > 5000 AND BALANCE >5000 DROP INDEX NCI ON DBO.TEST CREATE NONCLUSTERED INDEX NCI ON DBO.TEST (PRODUCTCODE,BALANCE) INCLUDE (ACCOUNTNUMBER) WHERE BALANCE >5000 SET STATISTICS IO ON SELECT PRODUCTCODE FROM dbo.TEST WHERE ACCOUNTNUMBER > 5000 AND BALANCE >5000 DROP INDEX NCI ON DBO.TEST
upvoted 3 times
...
Tellence
5 years, 2 months ago
Why put CustomerStatus as key-field. The field is already used in the where condition. I think the index with only CreatedDate is needed as key.
upvoted 8 times
...
ilysha2005
5 years, 4 months ago
Agree, but CustomerStatus = 1 not in answers. And why created clustered index but not nonclustered due to conditions make no changes to clustered index
upvoted 9 times
New_user
5 years, 3 months ago
Clustered index given in answer would sort table by date and status columns, so that's wrong choice. Nonclustered index meets 'no changes to primary key' requirement.
upvoted 13 times
...
lauferr
4 years, 11 months ago
You need to have small size index.
upvoted 2 times
...
...
neko
5 years, 4 months ago
I agree to ClydeZ.
upvoted 6 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago