1).

Scenario
DECLARE @count int
SET @count = 0
WHILE (@count < 100)
INSERT INTO X (ID) VALUES (@count)
SET @count = @count + 1
PRINT 'Test data generated for ' + CONVERT(varchar,@count) + ' rows!'

The sample code above is executed against a SQL Server from within an
application; after some time has passed, it is apparent that the application
is no longer responding.

Referring to the above scenario, what is the reason for the error?
Choice 1

The INSERT statement is missing the word "INTO" before the word "TestTable."
Choice 2

DECLARE fails because @count is a reserved word.
Choice 3

The PRINT statement fails because its output contains a function.
Choice 4

The WHILE loop goes into an infinite loop.
Choice 5

The PRINT statement fails because @count cannot be converted to varchar.

2).
Sample Code


What effect does WITH CUBE have on the query in the sample code above?
Choice 1

It adds a second rowset to the output with one column and one row containing the total
number of distinct customers in the Orders table.
Choice 2

It provides two additional rows that total up the number of customers in one and the
number of orders in the other.
Choice 3

It provides one additional row that totals up the number of customers who have placed
orders.
Choice 4

It provides an extra running total row for each different customer and an additional row for
the grand total of the COUNT(OrderID) column.
Choice 5

It provides one additional row that totals up the number of orders placed by all
3).

Which one of the following stored procedure calls forces an INSTEAD OF DELETE trigger to
fire after any other INSTEAD OF triggers?
Choice 1

sp_settriggerorderlast 'MyDeleteTrigger'
Choice 2

sp_settriggerorderlast 'MyDeleteTrigger','Delete'
Choice 3

sp_settriggerorder @triggername = 'MyDeleteTrigger', @order = 'last', @stmttype
= 'DELETE'
Choice 4

sp_helpindex 'MyDeleteTrigger','last','Delete'
Choice 5

sp_setspecial_columns 'MyDeleteTrigger','last'

4).
Sample
Query
Line# SQL
===== =====================
1. SELECT count(ALL),
2. col1
3. FROM ThatTable
4. WHERE col1 IN (1-10)
5. GROUP BY col1
6. HAVING COUNT(ALL) > 3

Assuming that the col1 column is of the integer data type, which one of the following lines
in the sample query above contains an error?
Choice 1

Line 1
Choice 2

Line 2
Choice 3

Line 3
Choice 4

Line 4
Choice 5

Line 5



5).
Sample Code


What is the ending value of variable @Var1 in the sample code above?
Choice 1

Null
Choice 2

1
Choice 3

4
Choice 4

5
Choice 5

6

6).
T-SQL Code TRY
SELECT * FROM TABLE1;
SELECT COL1 FROM TABLE2 WHERE COL2 = 5;
END TRY
CATCH
SELECT ERROR_MESSAGE() as ErrorMessage;
END CATCH;

What is wrong with the T-SQL code above?
Choice 1

TRY and CATCH are missing a BEGIN to the left of each.
Choice 2
The TRY block is missing a BEGIN...END construct.

Choice 3

The CATCH block is missing a BEGIN...END construct.
Choice 4

The END statements should be removed.
Choice 5

The TRY from END TRY should be removed.

7).
T-SQL
Statement
SELECT o.Price, o.Cost, (SELECT MAX(i.Quantity) FROM Items as i
WHERE i.OrderNum = o.OrderNum) as MaxQty FROM Orders as o

What does the T-SQL statement above display?
Choice 1

The columns named Price, Cost from Items, and Quantity from Orders
Choice 2

The columns named Price, Cost from Items, and MaxQty from Orders
Choice 3

The columns named Price, Cost from Orders, and Quantity from Items
Choice 4

The columns named Price, Cost from Orders, and Maxqty from Items
Choice 5

All columns from Items and from Orders

8).
Query Batch
1. DECLARE @isTrue char(1)
2. DECLARE @var char(10)

3. SET @var = 'alphabet'
4. If @var LIKE '%ABC%'
5. SET @isTrue = 'Y'
6. ELSE
7. SET @isTrue = 'N'

Upon completion of the query batch above and assuming DEFAULT SQL Server installation,
what is the value of @isTrue?
Choice 1

N
Choice 2
NULL--an error occurred on line 4
Choice 3

Y
Choice 4

NULL--an error occurred on line 1
Choice 5

NULL--an error occurred on line 3

9).
T-SQL Code UPDATE TOP (1) Customers SET FirstName = 'Ted' WHERE LastName = 'Anderson'

What does the above T-SQL Code do?
Choice 1

It updates no rows due to an error.
Choice 2

It updates all rows with the LastName of Anderson to a FirstName of Ted.
Choice 3

It updates a row with the LastName of Anderson to a FirstName of Ted.
Choice 4

It updates a row with the LastName of Ted to a FirstName of Anderson.
Choice 5

It updates all rows to a FirstName of Ted if the LastName of Anderson is not found.

10).

What is the format that allows XML-based inserts, updates, and deletes in SQL Server?
Choice 1

XSL
Choice 2

HTTP
Choice 3

Updategrams or OPENXML T-SQL function
Choice 4

IIS/ISAPI
Choice 5

SOAP

11).

If you begin a transaction, but SQL Server crashes before the transaction completes, what
happens to the transaction?
Choice 1

It is automatically rolled back.
Choice 2

The transaction is placed on hold until you complete it.
Choice 3

It is automatically committed on loading.
Choice 4

It causes a deadlock.
Choice 5

Part of the data from the transaction is committed.

12).

Which one of the following is NOT a type of constraint?
Choice 1

Primary key
Choice 2

Check
Choice 3

Foreign key
Choice 4

Cascade
Choice 5

Unique

13).

Which one of the following statements creates a new, empty table, named TABLE2, with the
same fields as TABLE1?
Choice 1

CREATE TABLE TABLE2 (SELECT * FROM TABLE1)
Choice 2

SELECT * INTO TABLE2 FROM TABLE1 WHERE NULL
Choice 3

SELECT TOP 0 * INTO TABLE2 FROM TABLE1
Choice 4

SELECT * INTO TABLE2 FROM TABLE1 WHERE 1=1
Choice 5

CREATE TABLE TABLE2 FROM TABLE1

14).
T-SQL Query MyTable
ColA
abcde
HELLO
THERE
my
Friend
partner
select ColA from MyTable
where ColA < 'hello'


How many rows does the query above return if the SQL Server uses the default sort order?
Choice 1

1 row
Choice 2

2 rows
Choice 3

3 rows
Choice 4

4 rows
Choice 5

5 rows

15).
Image


Given the table schema in the image above, which line or lines of the T-SQL statement
contain errors?
Choice 1

Line 1 only
Choice 2

Line 2 only
Choice 3

Line 3 only
Choice 4

Lines 1 and 2
Choice 5

Lines 2 and 3

16).
T-SQL
Statement
SELECT ROWID
FROM (SELECT ROW_NUMBER() OVER (ORDER BY EMPLOYEEID ASC) AS ROWID, * FROM
EMPLOYEE) AS T

How many rows are displayed from the T-SQL statement above if the EMPLOYEE table has
five rows?
Choice 1

1
Choice 2

2
Choice 3

3
Choice 4
4

Choice 5

5

17).
Sample Code


Referring to the sample code above, what is the ending value of local variable @count?
Choice 1

Null
Choice 2

0
Choice 3

2
Choice 4

8
Choice 5

16

18).

What are two important differences between OLTP and OLAP?
Choice 1

OLTP is volatile; OLAP is non-volatile; OLTP contains more historical data than OLAP.
Choice 2

OLTP supports daily operations; OLAP supports summary data; OLAP models are more
relational than OLTP models.
Choice 3

OLTP accesses small amounts of data per transaction; OLAP accesses large amounts of
data; OLTP is more closely related to EIS than OLAP is to EIS.
Choice 4

OLTP supports daily operations; OLAP supports summary data; OLTP is more
concerned with transaction isolation than OLAP.
Choice 5
OLTP is non-volatile; OLAP is volatile; OLAP returns summaries of data very quickly


19).
T-SQL
Statement
SELECT * FROM PRODUCTS WHERE PRODUCTID IN (SELECT PRODUCTID FROM
ONSALEPRODUCTS)

What does the T-SQL statement above select?
Choice 1

All rows from ONSALEPRODUCTS that have a PRODUCTID in the PRODUCTS table
Choice 2

All rows from PRODUCTID that have PRODUCTS in the ONSALEPRODUCTS table
Choice 3

All rows from ONSALEPRODUCTS that have a PRODUCTID in the PRODUCTID table
Choice 4

All rows from PRODUCTS that have a PRODUCTID in the PRODUCTID table
Choice 5

All rows from PRODUCTS that have a PRODUCTID in the ONSALEPRODUCTS table

20).

NULL is equivalent to which one of the following values?
Choice 1

Integer 0 or varchar ''
Choice 2

Integer 0
Choice 3

Integer -1 or varchar ''
Choice 4

Integer -1
Choice 5

Unknown

21).

Which one of the following types of database objects is bound to a table and executes a
batch of code whenever a specific data modification action occurs?
Choice 1

Trigger
Choice 2

Rule
Choice 3

Constraint
Choice 4

Stored procedure
Choice 5

Default

22).
Scenario You need to display all rows of data from TABLE1 and TABLE2, including duplicates.

Referring to the scenario above, which one of the following T-SQL statements do you use?
Choice 1

SELECT * FROM TABLE1
UNION
SELECT * FROM TABLE2
Choice 2

SELECT * FROM TABLE1
UNION *
SELECT * FROM TABLE2
Choice 3

SELECT * FROM TABLE1
MERGE
SELECT * FROM TABLE2
Choice 4

SELECT * FROM TABLE1
JOIN
SELECT * FROM TABLE2
Choice 5

SELECT * FROM TABLE1
UNION ALL
SELECT * FROM TABLE2

23).
T-SQL Code


If you are logged onto SQL Server as the System Administrator, and you execute the T-SQL
code above, which one of the following results do you get?
Choice 1
0 sa 987

Choice 2

1 sa 123
Choice 3

1 ...\Administrator 123
Choice 4

1 dbo 987
Choice 5

0 ...\Administrator 987

24).

Which one of the following T-SQL statements is directly permitted in a Stored Procedure?
Choice 1

CREATE VIEW
Choice 2

ALTER FUNCTION
Choice 3

ALTER PROCEDURE
Choice 4

CREATE TRIGGER
Choice 5

CREATE TABLE

25).
Scenario
Your application uses table level INDEX hints to increase the performance of certain SELECT
queries.

Referring to the scenario above, which one of the following situations causes the hints to
become obsolete?
Choice 1

A change in index strategy is made on the table.
Choice 2

The table is altered to modify the nullability of certain columns.
Choice 3

The addition of a trigger to the table referenced by the hint.
Choice 4

A check constraint is added to the table.
Choice 5

The table becomes referenced by a FOREIGN KEY constraint in a subordinate table.

26).
Scenario You need to store international names that are limited to 100 characters in length.

Referring to the scenario above, which one of the following data types uses the LEAST
storage space and allows for an index?
Choice 1

nvarchar
Choice 2

binary
Choice 3

ntext
Choice 4

char
Choice 5

cursor

27).

Which one of the following is NOT a characteristic of a correlated subquery?
Choice 1

Subquery returns a single value or list of values for each row of the outer query.
Choice 2

The same task can often be accomplished using joins.
Choice 3

Subquery must use grouping and aggregation.
Choice 4

Inner query is executed once for each row of the outer query.
Choice 5

Inner query relies on data from the outer query.

28).
T-SQL Code
IF EXISTS(SELECT COL1 FROM TABLE1 WHERE COL1 IS NOT NULL)
ROLLBACK TRANSACTION

UPDATE TABLE1 SET COL1 = Null

What happens to the UPDATE statement in the T-SQL code above if the ROLLBACK
TRANSACTION is executed?
Choice 1

It is not rolled back.
Choice 2

It does not execute.
Choice 3

It is rolled back.
Choice 4

It causes an error.
Choice 5

It is never part of any transaction

29).
Sample Code


What is the value of @count after the sample code above executes?
Choice 1

0
Choice 2

10
Choice 3

15
Choice 4

20
Choice 5

NULL

30).
T-SQL Code RETURN @avar.query('Product/Prices')

The above T-SQL code is an example of using which one of the following data types?
Choice 1

text
Choice 2

nvarchar
Choice 3

ntext
Choice 4

varchar
Choice 5

xml

Master your semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master your semester with Scribd & The New York Times

Cancel anytime.