11.
Which of the following functions would you consider using to generate surrogate keys?
(Choose all that apply.)
- A.NEWID
- B.NEWSEQUENTIALID
- C.GETDATE
- D.CURRENT_TIMESTAMP
- Answer & Explanation
- Report
Answer : [A, B]
Explanation :
Explanation :
A. Correct: The NEWID function creates GUIDs in random order. You would consider
it when the size overhead is not a major issue and the ability to generate a unique
value across time and space, from anywhere, in random order is a higher priority. B. Correct: The NEWSEQUENTIALID function generates GUIDs in increasing order within the machine. It helps reduce fragmentation and works well when a single session loads the data, and the number of drives is small. However, you should carefully consider an alternative using another key generator, like a sequence object, with a smaller type when possible. C. Incorrect: There’s no assurance that GETDATE will generate unique values; therefore, it’s not a good choice to generate keys. D. Incorrect: The CURRENT_TIMESTAMP function is simply the standard version of GETDATE, so it also doesn’t guarantee uniqueness. |
12.
What is the difference between the simple CASE expression and the searched CASE
expression?
- A.The simple CASE expression is used when the database recovery model is simple, and the searched CASE expression is used when it’s full or bulk logged.
- B.The simple CASE expression compares an input expression to multiple possible expressions in the WHEN clauses, and the searched CASE expression uses independent predicates in the WHEN clauses.
- C.The simple CASE expression can be used anywhere in a query, and the searched CASE expression can be used only in the WHERE clause.
- D.The simple CASE expression can be used anywhere in a query, and the searched CASE expression can be used only in query filters (ON, WHERE, HAVING).
- Answer & Explanation
- Report
Answer : [B]
Explanation :
Explanation :
A. Incorrect: CASE expressions have nothing to do with the database recovery
model. B. Correct: The difference between the two is that the simple form compares expressions and the searched form uses predicates. C. Incorrect: Both CASE expressions are allowed wherever a scalar expression is allowed—anywhere in the query. D. Incorrect: Both CASE expressions are allowed wherever a scalar expression is allowed—anywhere in the query. |
13.
What does the term three-valued logic refer to in T-SQL?
- A.The three possible logical result values of a predicate : true, false, and NULL
- B.The three possible logical result values of a predicate : true, false, and unknown
- C.The three possible logical result values of a predicate : 1, 0, and NULL
- D.The three possible logical result values of a predicate : -1, 0, and 1
- Answer & Explanation
- Report
Answer : [B]
Explanation :
Explanation :
A. Incorrect: NULL is not part of the three possible logical results of a predicate in
T-SQL. B. Correct: Three-valued logic refers to true, false, and unknown. C. Incorrect: 1, 0, and NULL are not part of the three possible logical results of a predicate. D. Incorrect: -1, 0, and 1 are not part of the three possible logical results of a predicate. |
14.
Which of the following literals are language-dependent for the DATETIME data type?
(Choose all that apply.)
- A.'2012-02-12'
- B.'02/12/2012'
- C.'12/02/2012'
- D.'20120212'
- Answer & Explanation
- Report
Answer : [A, B, C]
Explanation :
Explanation :
A. Correct: The form '2012-02-12' is language-neutral for the data types DATE,
DATETIME2, and DATETIMEOFFSET, but language-dependent for DATETIME and
SMALLDATETIME. B. Correct: The form '02/12/2012' is language-dependent. C. Correct: The form '12/02/2012' is language-dependent. D. Incorrect: The form '20120212' is language-neutral. |
15.
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 < '20120213'
- Answer & Explanation
- Report
Answer : [B, E]
Explanation :
Explanation :
A. Incorrect: This predicate applies manipulation to the filtered column, and hence
isn’t a search argument. B. Correct: The LIKE predicate is a search argument when the pattern starts with a known prefix. C. Incorrect: The LIKE predicate isn’t a search argument when the pattern starts with a wild card. D. Incorrect: The LIKE predicate isn’t a search argument when the pattern starts with a wild card. E. Correct: Because no manipulation is applied to the filtered column, the predicate is a search argument. |