exam questions

Exam 70-761 All Questions

View all questions & answers for the 70-761 exam

Exam 70-761 topic 1 question 115 discussion

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

HOTSPOT -
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 query a database that includes two tables: Project and Task. The Project table includes the following columns:

The Task table includes the following columns:

Users report performance issues when they run the following query:

You need to improve query performance and limit results to projects that specify an end date.
How should you complete the Transact-SQL statement? To answer, select the appropriate Transact-SQL segments in the answer area.
Hot Area:

Show Suggested Answer Hide Answer
Suggested Answer:
Wildcard character %: Any string of zero or more characters.
For example: If the LIKE '5%' symbol is specified, the Database Engine searches for the number 5 followed by any string of zero or more characters.
References:
https://docs.microsoft.com/en-us/sql/t-sql/language-elements/like-transact-sql

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
Vermonster
4 years, 4 months ago
Poor performance on search when the side of the predicate with the column being searched has a function - that's the reference to SARG (search argument)
upvoted 1 times
...
kimalto452
4 years, 4 months ago
Answer correct, sargable improve perfomance
upvoted 2 times
...
TomAbg
4 years, 5 months ago
Hello. Correct answer in second block : Where T.name LIKE 'TEST%'.
upvoted 1 times
...
Kiruu23
4 years, 8 months ago
We have to provide solution for performance issue. Left() is a function and Like is not so, in comparison to LEFT()Funtion, LIKE is more preferable to use.
upvoted 2 times
...
arindam_pal
4 years, 10 months ago
I think the correct answer is LEFT(expression, length)=TEST, as in the question substring is matching with TEST and TEST% can return any string which starts with TEST.
upvoted 1 times
ChargedNeutrons
4 years, 8 months ago
LEFT modifies the column. If you want to improve performance, you can't modifies the column.
upvoted 1 times
...
...
cyan
5 years, 2 months ago
I think the predicate should be T.TaskName like '%TEST%'
upvoted 3 times
xd1
5 years ago
no, string index starts at 1 in sql, and as seen in example you want 1-4 to be like test. no need for wildcard before that as you do not want anything actually in front of TEST
upvoted 7 times
Anette
4 years, 11 months ago
Correct
upvoted 1 times
...
melvin9900
4 years, 10 months ago
Will T.TaskName like 'TEST' work if the TaskName starts as 'TESTING'.
upvoted 1 times
...
...
...
Mag53
5 years, 3 months ago
About comment avramov: Task is to improve the first query with an alternative query that is more performant. The SUBSTRING clause in the original query clearly shows that every Taskname starts with the four letters TASK -> solution is correct
upvoted 3 times
...
avramov
5 years, 6 months ago
isnt it the second box 'Test' because the Substring states starting from the 1st symbol and continuing to the 4th? i. e. lenght of 4
upvoted 1 times
Anette
4 years, 11 months ago
if you substring any string first 4 characters its the same as you compare with LIKE (4 characters) %, where % stand for no matter what. So its the second Box
upvoted 1 times
...
...
Dieter
5 years, 8 months ago
Is a wild card comparison actually better in performance issues compared to "LEFT(expression, length) LIKE 'TEST'"? in opinion it is not. any hints?
upvoted 2 times
BabyBee
4 years, 5 months ago
Yes, it is better, because what you don't want to do is apply functions to the column of the table in the WHERE clause, the one you're using to compare, rather have the functions in right side on the word you're comparing your column table to.
upvoted 1 times
...
AshleyLiang
5 years, 8 months ago
Yes. This is related a terminology named Sargable: https://www.sqlshack.com/how-to-use-sargable-expressions-in-t-sql-queries-performance-advantages-and-examples/
upvoted 12 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