1. While using the IN operator, the SQL engine will scan all records fetched from the inner query.
A) True
B) False
2. Consider the below table.
Table tab_1:
ID | Column_2 | Name |
---|---|---|
11 | F1 | Fardeen |
22 | G1 | Gautam |
33 | H1 | Harish |
44 | I1 | Fardeen |
55 | E1 | Eklavya |
NULL | NULL | NULL |
0 | 0 | 0 |
What is the result of the below query:
select * from tab_1
where '0' in (select ID from Tab_1 where ID in (0))
A)
ID | Column_2 | Name |
---|---|---|
0 | 0 | 0 |
B)
ID | Column_2 | Name |
---|---|---|
NULL | NULL | NULL |
C)
ID | Column_2 | Name |
---|---|---|
11 | F1 | Fardeen |
22 | G1 | Gautam |
33 | H1 | Harish |
44 | I1 | Fardeen |
55 | E1 | Eklavya |
NULL | NULL | NULL |
0 | 0 | 0 |
D)
None of above
3. The select list of a subquery introduced by EXISTS almost always consists of ………. There is no reason to list column names as you are just verifying whether rows that meet the conditions specified in the subquery exist.
A) percent (%)
B) asterisk (*)
C) Comma (,)
D) None of above
4. Only EXISTS can be prefixed with NOT but IN cannot be.
A) True
B) False
5. When EXISTS is used, SQL Server stops as soon as it finds .......... record that matches the criteria.
A) Middle
B) Last
C) One
D) None of above
6. NOT EXISTS works like EXISTS, except the WHERE clause in which it is used is satisfied if ........... rows are returned by the subquery.
A) Two
B) Unpinned
C) TOP
D) No
7. The keyword EXISTS is not preceded by a ............
A) constant
B) column name
C) other expression
D) All of above
8. Consider the below table.
Table dbo.tab_1
ID | Column_2 | Name |
---|---|---|
11 | F1 | Fardeen |
22 | G1 | Gautam |
33 | H1 | Harish |
44 | I1 | Fardeen |
55 | E1 | Eklavya |
What is the result of the below query:
DECLARE @InList varchar(100)
SET @InList = '11,12,33,44'
SELECT *
FROM Tab_1
WHERE ','+@InList+',' LIKE ',%'+CAST(Id AS varchar)+',%'
A)
ID | Column_2 | Name |
---|---|---|
11 | F1 | Fardeen |
33 | H1 | Harish |
44 | I1 | Fardeen |
B)
ID | Column_2 | Name |
---|---|---|
11 | F1 | Fardeen |
22 | G1 | Gautam |
33 | H1 | Harish |
44 | I1 | Fardeen |
C)
ID | Column_2 | Name |
---|---|---|
11 | F1 | Fardeen |
22 | G1 | Gautam |
33 | H1 | Harish |
44 | I1 | Fardeen |
55 | E1 | Eklavya |
D) None of above
9. Consider the below table.
Table tab_1
ID | Column_2 | Name |
---|---|---|
11 | F1 | Fardeen |
22 | G1 | Gautam |
33 | H1 | Harish |
44 | I1 | Fardeen |
55 | E1 | Eklavya |
NULL | NULL | NULL |
What will be the result of following query:
SELECT ID, column_2, Name
FROM dbo.tab_1
WHERE EXISTS (SELECT NULL)
A)
ID | Column_2 | Name |
---|---|---|
11 | F1 | Fardeen |
22 | G1 | Gautam |
33 | H1 | Harish |
44 | I1 | Fardeen |
55 | E1 | Eklavya |
B) It will show an error message.
C)
ID | Column_2 | Name |
---|---|---|
NULL | NULL | NULL |
D)
ID | Column_2 | Name |
---|---|---|
11 | F1 | Fardeen |
22 | G1 | Gautam |
33 | H1 | Harish |
44 | I1 | Fardeen |
55 | E1 | Eklavya |
NULL | NULL | NULL |
10. Exists uses a ............ to join values from a column to a column within the subquery.
A) View
B) Join
C) Subquery
D) Clustered Index
Answers