Chapter 3 - Lesson 1 Flashcards

1
Q

What is a searched argument?

A

A column used in the where clause without manipulation is caled a searched argument

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why is it important to use searched arguments?

A

Because sql server otherwise will not use indexes to search for that argument and perform instead a table scan, which is slow.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
Is this a searched argument?
WHERE COALESCE(e.region,' ' ) <> 'wa'
A

no, Because Coalesce is performed on each row, sql server will not use a possible index on that column.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How can i make region in COALESCE(e.region,’ ‘ ) <> ‘wa’ a searched argument and still get the same rows back?

A

WHERE e.region <> ‘wa’ OR e.region IS NULL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
Is shipped date a sa?
WHERE COALESCE(shippeddate, '19000101') = COALESCE(@DT, '19000101');
A

Becasuse we are manipulating it with COALESCE, preventing sql server from using indexes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can i solve the problem that COALESCE(shippeddate, ‘19000101’) = COALESCE(@DT, ‘19000101’) is not a searched argument?

A

WHERE shippeddate = @DT OR (shippeddate IS NULL AND @DT IS NULL)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the precedence when it comes to logical operators AND , OR and NOT and the parentheses(pr. parentesees)?

A
      1. ()
    • 2.NOT
    • 3.AND
    • 4.OR
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Why will the follwoing predicate influence the performance of a query, suppose u know that lastname is nvarchar?
– WHERE lastname = ‘Davis’;

A

Now the column lastname is not a searched argument anymore because of the (manupulation) implicit convertion to varchar, so no index will be used.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What rule do you have to follow when it comes to wild cards to not influence the performance?

A

never use the wildcard at the beginning of the charachters, because your column will not be a searched argument anymore

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which one is a sa?

cl1 like ‘%ABC%’ is not good, like ‘ABC%’

A

the second

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the form of a filter predicate that can rely on index ordering called?

A

A search argument, or SARG, for short.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the standard way(style) to compare dates?

A

‘yyyymmdd’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Why is the use of between when comparing dates not recommended?

A

‘20071231’ and ‘20071231 23:59:59.999’ will also.

get records of 1 jan 2008

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Hoe bepaalt sql server wat de stijl is van een gegeven literal bijvoorbeeld ‘25-08-1983’?

A

Dit is afhankelijk van je taal instelling!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Welke form van date is niet afhankelijk van je taal instelling?

A

‘yyyymmdd’ oftewel ‘19832508’.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Voor welke date datatype is de stijl ‘1983-08-25’ niet taalonafhankelijk?

A

Datetime and smalldatetime

17
Q

What does the term three-valued logic refer to in T-SQL?

A

true, false and unknown

18
Q

Which of the following literals are language-dependent for the DATETIME data type?

  • -A. ‘2012-02-12’
  • -B. ‘02/12/2012’
  • -C. ‘12/02/2012’
  • -D. ‘20120212’
A

a,b,c

19
Q

When is a predicate a searched argument, 3 situations?

A

when the columns are not manipulated

    • patern in LIKE predicate starts with a known prefix like: ‘A%’
    • Patern in LIKE predicate starts doesn’t start with a wild card.
20
Q

Which of the following predicates are search arguments? (Choose all that apply.)

  • -A. DAY(orderdate) = 1
  • -B. companyname LIKE ‘A%’
  • -C. companyname LIKE ‘%A%’
  • -D. companyname LIKE ‘%A’
  • -E. orderdate > = ‘20120212’ AND orderdate
A

– B,E