Você está na página 1de 249

Database

files and
Data files
Views and It is mandatory to define at least one
Partition secondary data file for a database.
1 True or False Knowledge Easy Tables State True or False. 1

Consider the following statements with


respect to partitioned tables:

Statement 1: Partitioned tables allows


data rows to be split horizontally
based on values in a key column(like
date)

Statement 2: DML
operations(INSERT, UPDATE,
Database DELETE) for partitioned(multiple
files and partition) tables are different from that
Data files of a single partition table.
Views and
Single Comprehensi Partition Which of the following is applicable for
2 Choice on Easy Tables above? 1

Database
files and
Data files
Views and
Multiple Comprehensi Partition Which of the following are correct with
3 Choice on Average Tables respect to Filegroups?(Choose 2) 2

Database
files and
Data files When creating a database, which of
Views and the following should be considered
Multiple Comprehensi Partition when selecting the location of the
4 Choice on Average Tables database files?(Choose 3) 3

Consider the following statements with


respect to Views:

Statement 1: Index on a view takes up


physical storage and requires
maintenance.
Database Statement 2: Local partitioned view
files and utilises base tables that reside on the
Data files same server.
Views and
Single Comprehensi Partition Which of the following is applicable for
5 Choice on Average Tables above? 1

Stored Which of the following are features of


Multiple Comprehensi procedures a local temporay stored procedure?
6 Choice on Average and functions (Choose 2) 2
Stored Which of the following are correct for
Multiple Comprehensi procedures temporary tables used in Stored
7 Choice on Average and functions procedures?(Choose 2) 2

Consider the following statements with


respect to Nested stored procedures:

Statement 1 : There is no limit to the


number of levels to which procedures
can be nested.
Statement 2 : The number of stored
procedures that can be called from
within a single procedure is limitless.
Statement 3 : A stored procedure can
call itself upto a defined maximum
limit
Stored
Single Comprehensi procedures Which of the following is applicable for
8 Choice on Average and functions above statements? 1

Stored Which of the following attributes


Multiple Comprehensi procedures characterise System Stored
9 Choice on Average and functions Procedures?(Choose 3) 3

Consider the following statements with


respect to CLR procedures:

Statement 1: CLR procedures are


typically written in Microsoft C or
Visual C++.
Statement 2: CLR procedures are
safe and secure because they run
within the Appdomain boundary and it
cannot access random SQL Server
memory locations.
Stored
Single Comprehensi procedures Which of the following is applicable for
10 Choice on Average and functions above statements? 1

Stored Which of the following cannot be


Multiple Comprehensi procedures passed as input parameter values to a
11 Choice on Average and functions Stored procedure?(Choose 2) 2
Consider the following statement:

Select title_id, price, type from titles


where price >
dbo.AverageBookPrice('comp_scienc
e')
Stored
Comprehensi procedures What kind of a User Defined Function
12 True or False on Average and functions is used in the above statement? 1

Consider the following statements with


respect to User defined functions:

Statement 1: A User Defined Function


cannot generate permanent changes
to any resource whose scope extends
beyond the function.
Statement 2: The only changes that
can be made by the SQL statements
in a function are to the objects that are
local to the function, like local cusors
or variables.
Stored
Single Comprehensi procedures Which of the following is applicable for
13 Choice on Average and functions the above? 1

You are currently working with an


application with lage processor-
intensive calculations.
Stored
Single Comprehensi procedures Which of the following stored
14 Choice on Average and functions procedure would you prefer? 1

Which of the following error type can


Stored be handled within a TRY..CATCH
Single Comprehensi procedures construct of handling errors in stored
15 Choice on Average and functions procedures? 1
Stored Which of the following type of
Single Comprehensi procedures statement are allowed to be included
16 Choice on Average and functions in a User Defined Function? 1

You have to perform operations like


inserts, deletes, updates on the
contents of a table variable before
returning a result set.

Stored Which of the following User Defined


Single Comprehensi procedures Function will be suitable to define for
17 Choice on Average and functions the above scenario? 1

Stored
procedures
and Which of the following is not an
18 Single ChoiceComprehension
Average Functions advantage of Stored Procedure? 1

Which of the following stored


Stored procedures are ideal candidates to be
Multiple Comprehensi procedures re-written as User Defined Functions?
19 Choice on Complex and functions (Choose 2) 2

You have a stored procedure and you


need to make some modifications to it.
Stored
Multiple Comprehensi procedures Which of the following ways can this
20 Choice on Complex and functions be done?(Choose 2) 2

Consider the following scenario:


The creator of a stored procedure also
owns the tables that it references.

Statement 1: An user can execute the


stored procedure but cannot access
the referenced table unless the creator
grants access to the table
Statement 2: An user can execute the
stored procedure and inherits the
rights on the referenced table from the
owner within the context of the stored
procedure
Stored
Single Comprehensi procedures Which of the following is applicable for
21 Choice on Complex and functions the above? 1

Which of the following option defines a


cursor that makes a temporary copy of
22 Single ChoiceKnowledge Average Cursors the data to be used by the cursor? 1
Which of the following options is used
to retrieve the second record from a
23 Single ChoiceComprehension
Average Cursors table? 1
Consider the following statements with
respect to cursors:

Statement 1 :Cursor processing is


faster than set-oriented processing
and causes locks to be held for
shorter period of time.
Statement 2 :Cursors can be used to
minimise locking contention for
updates and deletions of a large
number of rows in a table.

Single Comprehensi Which of the following is applicable for


24 Choice on Average Cursors above? 1

Consider the following statements with


respect to use of cursors in stored
procedures:

Statement 1: A stored procedure can


pass cursor variables as output
parameters only.
Statement 2: You must use SELECT
statement to assign a cursor to a
cursor variable.

Single Comprehensi Which of the following is applicable for


25 Choice on Average Cursors above? 1

Consider the following with respect to


types of cursors:

Statement 1: A global cursor defined


in a stored procedure is available
even after the connection closes.
Statement 2: A local cursor remains in
scope even after the stored procedure
that declared it terminates

Single Comprehensi Which of the following is applicable for


26 Choice on Average Cursors above? 1

Below is a code snippet for cursor:

01 USE AdventureWorks
02 GO
03 DECLARE contact_cursor
CURSOR FOR
04 SELECT LastName FROM
Person.Contact
05 WHERE LastName LIKE 'B%'
06 ORDER BY LastName
07 OPEN contact_cursor
08 FETCH NEXT FROM
contact_cursor
09 WHILE @@FETCH_STATUS = 0
10 BEGIN
11 ---- Missing Line
12 END
13 ---- Missing Line
14 ---- Missing Line

Which of the following lines of code


Multiple Comprehensi can be correctly fitted into the missing
27 Choice on Average Cursors lines?(Choose 3) 3
Which of the following cursor creation
option specifies that all fetch options
(FIRST,LAST,PRIOR,NEXT,RELATIV
28 Single ChoiceComprehension
Average Cursors E,ABSOLUTE) are available? 1

The INSTEAD of trigger can be


applied to a view and triggered based
Triggers and on the modifications to the view.
29 True or False Knowledge Easy Indexes State True or False. 1

Single Comprehensi Triggers and Which of the following is limitation of


30 Choice on Average Indexes INSTEAD of trigger? 1

In case of defining multiple triggers for


an UPDATE action on a given table,
Multiple Comprehensi Triggers and which of the following are correct
31 Choice on Average Indexes trigger order values?(Choose 3) 3

Single Comprehensi Triggers and For which of the following it is ideal to


32 Choice on Average Indexes define non-clustered indexes? 1

Referential integrity can be enforced


by using DML triggers.

Which of the following are other


methods by which the same
Multiple Comprehensi Triggers and enforcement can be achieved?
33 Choice on Average Indexes (Choose 2) 2

Triggers and Which of the following is a perfect


34 Single ChoiceKnowledge Easy Indexes match with reference to an Index? 1

Where are SQL Server user names


35 Single ChoiceKnowledge Easy SQL server 2005
andoverview
Passwords stored in sql server? 1
A table can not have more than one
clustered index.
36 True or False Knowledge Easy SQL server 2005
State
overview
True or False 1
Assume that you have a Database
ERP in which there is a field called
ERP_NUM which is used in several
places. The column has a specific
behaviour which is different from the
traditional SQL server data types.

SQL server Which of the following feature we can


Single Comprehensi 2005 use to address the above
37 Choice on Complex overview requirement? 1

Sqlserver uses a workspace for


storing temporary objects such as
tables and stored procedures. This
workspace is recreated each time the
sqlserver is restarted.

Which of the followng correctly


describes the above workspace
38 Single ChoiceApplication Average SQL server 2005
database?
overview 1

Which of the following are correct for


39 Multiple Choice
Application Complex SQL server 2005
indexed
overview
views?(Choose 2) 2

An user wants to grant all users query


privileges on his/her DEPT table.

Which of the following SQL statement


40 Single ChoiceApplication Complex SQL server 2005
will overview
help him/her accomplish this? 1

Implementin
g Data
integrity,Sub
queries and
Joins & T-
SQL
enhancemen
ts and When of the following subquery takes
41 Single ChoiceKnowledge Easy functions parameters from its parent query? 1

Implementin
g Data
integrity,Sub
queries and
Joins & T-
SQL
enhancemen
ts and Which of the following is NOT used to
42 Single ChoiceComprehension
Average functions combine data from multiple tables? 1

Implementin
g Data
integrity,Sub
queries and
Joins & T-
SQL
enhancemen Which of the following helps us to
ts and create and populate a new table with
43 Single ChoiceComprehension
Average functions the data of an existing table? 1
Implementin
g Data
integrity,Sub
queries and
Joins & T-
SQL A set of statements is to be executed
enhancemen 10 times.
ts and Which of the following constructs can
44 Single ChoiceComprehension
Average functions we use for this task? 1

Implementin
g Data
integrity,Sub
queries and
Joins & T-
SQL Which of the following type of integrity
enhancemen is correct for the statement -
ts and 'Ensures that the values in a column
45 Single ChoiceComprehension
Average functions are within the Specified Range'? 1

Implementin
g Data
integrity,Sub
queries and
Joins & T-
SQL
enhancemen Which of the following type of integrity
ts and maintains the relationship between
46 Single ChoiceComprehension
Average functions tables in a database? 1

Implementin
g Data
integrity,Sub
queries and
Joins & T-
SQL
enhancemen Which of the following type of integrity
ts and ensures each record in a table is
47 Single ChoiceComprehension
Average functions Unique? 1
You work as a database developer at
ABC.Inc.com.
The ABC sales staff wants to track
Implementin sales by multiple parameters such as
g Data age, country to be able to spot
integrity,Sub relevant sales patterns.
queries and To produce such information you need
Joins & T- to join four tables from the highly
SQL normalized database.
enhancemen
ts and Which of the following suggestion will
48 Single ChoiceApplication Average functions make the query response time faster? 1
Examine the structure of the
EMPLOYEES and
NEW_EMPLOYEES tables

employees
employee_id INT Primary Key
first_name VARCHAR (25)
Implementin last_name VARCHAR(25)
g Data hire_date DATE DATETIME
integrity,Sub
queries and new_employees
Joins & T- employee_id INT Primary Key
SQL name VARCHAR(50)
enhancemen
ts and Which of the following UPDATE
49 Single ChoiceApplication Average functions statement is valid for the above? 1

Implementin
g Data
integrity,Sub
queries and
Joins & T-
SQL
enhancemen
ts and Which of the following is a valid
50 Single ChoiceApplication Complex functions statement about sub queries? 1
Implementin During the major system upgrade,
g Data multiple data changes are going to be
integrity,Sub made. You would like to implement
queries and various changes without disturbing
Joins & T- any of the existing data.
SQL
enhancemen Which of the following operations do
ts and not affect any existing data values?
51 Multiple Choice
Application Complex functions (Choose 3) 3

Consider the following statements:

CREATE PARTITION FUNCTION


SalesFigures (datetime)

AS RANGE RIGHT FOR VALUES

Database ('01/01/1993', '01/01/1994',


files and '01/01/1995')
Data files GO
Views and
Single Partition What does the above partition function
52 Choice Application Complex Tables achieve? 1
Consider the following statements:

A view is created as follows:


CREATE VIEW EmployeeView
as
SELECT empid, birthdate, gender,
hiredate
from Hr.Employees
where hiredate > '2/1/07'

The following select statement uses


the above view:
Database
files and SELECT * from EmployeeView
Data files where birthdate > '3/1/65'
Views and
Single Partition What does the above SELECT
53 Choice Application Complex Tables statement retrieve? 1

Consider the following statements:

SELECT name AS view_name


,SCHEMA_NAME(schema_id) AS
schema_name

,OBJECTPROPERTYEX(object_id,'IsI
ndexed') AS IsIndexed

,OBJECTPROPERTYEX(object_id,'IsI
ndexable') AS IsIndexable
Database ,create_date
files and ,modify_date
Data files FROM sys.views;
Views and
Single Partition What does IsIndexable return in the
54 Choice Application Complex Tables above statement? 1

Consider the following statements for


creation of a view:

CREATE VIEW Titleview AS


select title, au_ord, au_lname,price,
ytd_sales, pub_id
from authors, titles, titleauthor
where authors.au_id =
titleauthor.au_id
Database AND titles.title_id =
files and titleauthor.title_id
Data files
Views and In case the above schema needs to
Multiple Partition qualify for creation for an index, which
55 Choice Application Complex Tables of the following are missing? 2
Consider the following statements for
creation of a view:

CREATE VIEW Titleview AS


select title, au_ord, au_lname,price,
ytd_sales, pub_id
from authors, titles, titleauthor
where authors.au_id =
titleauthor.au_id
Database AND titles.title_id =
files and titleauthor.title_id
Data files
Views and In case the above schema needs to
Partition qualify for creation for an index, which
56 Single ChoiceApplication Complex Tables of the following are missing? 1

Assume that there is an indexed view


defined called prod.product_details.
Database
files and Which of the following gives the right
Data files example of using the view where SQL
Views and server will process the query by
Partition accessing data directly from the base
57 Single ChoiceApplication Complex Tables tables and ignore the indexed views. 1

Consider the following statements:

ALTER DATABASE Employee


Database MODIFY FILE (Name =
files and Employee_log,
Data files FILENAME = 'C:\Employee_log.ldf')
Views and
Partition What does the above statement
58 Single ChoiceApplication Complex Tables achieve? 1

Consider the following statements:


CREATE TABLE dbo.parameter
Database (tableid int identity
files and tabledesc shortdesc)
Data files
Views and Which of the following give the
Partition possible interpretations of use of
59 Single ChoiceApplication Complex Tables shortdesc as datatype?(Choose 2) 2

Consider the following statements:

CREATE PARTITION SCHEME


CustPS1
AS PARTITION CustPS1
ALL to ([PRIMARY])
GO

CREATE TABLE
dbo.customers_p1(cust_id,
Database cust_name, order_dt)
files and ON CustPS1(order_dt)
Data files GO
Views and
Partition What does the above statement
60 Single ChoiceApplication Complex Tables achieve? 1
Consider the following statements:

CREATE TABLE dbo.Table1


(Tableid int null,
Tabledesc varchar(50) null)
ON [userdata_FG]

Database CREATE CLUSTERED INDEX


files and [ci_table1] on [dbo].[Table1]
Data files ( [Tableid] ASC)
Views and
Partition What is the outcome of the above
61 Single ChoiceApplication Complex Tables statements? 1

Assume there is a table emp defined


with columns as
emp_id smallint
emp_name varchar(30)
emp_address text
Database
files and Supposing you want to modify the
Data files above table to make the emp_address
Views and column as varchar(40)
Partition which of the following ia a valid
62 Single ChoiceApplication Complex Tables command to make the change? 1

Assume there is a table emp defined


with columns as
emp_id smallint
emp_name char
Database emp_address char
files and
Data files Which of the following command can
Views and be issued to change the datatype of
Partition column emp_address from char to
63 Single ChoiceApplication Complex Tables nchar? 1

Assume there is a table emp defined


with columns as
emp_id smallint
emp_name char
Database emp_address char
files and
Data files In case you want to add a new column
Views and emp_gender after the emp_name
Partition column, which of the following can be
64 Single ChoiceApplication Complex Tables used? 1

Assume there is a table emp defined


with columns as
emp_id smallint
Database emp_name char
files and emp_address text
Data files
Views and In case you want to add a new column
Partition emp_gender to the above table, which
65 Single ChoiceApplication Complex Tables of the following can be used? 1
Consider the following statement:

CREATE VIEW sales.sales_sum_vu


as
SELECT datepart(yy, orderdate) as
'order_year',
datepart(mm, orderdate) as
'order_month',
sum(totaldue)
Database FROM sales.sales_order
files and GROUP BY datepart(yy, orderdate),
Data files datepart(mm, orderdate)
Views and
Partition What is the outcome of the above
66 Single ChoiceApplication Complex Tables create statement? 1

Consider the following statement:

CREATE VIEW sales.sales_sum_vu


as
SELECT datepart(yy, orderdate) as
'OrderYear',
datepart(mm, orderdate) as
'OrderMonth',
sum(totaldue) as 'TotalDue'
FROM sales.sales_order
Database GROUP BY datepart(yy, orderdate),
files and datepart(mm, orderdate)
Data files ORDER BY OrderYear, OrderMonth
Views and
Partition What is the outcome of the above
67 Single ChoiceApplication Complex Tables create statement? 1

Consider the following statements:

CREATE VIEW sales.sales_sum_vu


as
SELECT datepart(yy, orderdate) as
'OrderYear',
datepart(mm, orderdate) as
'OrderMonth',
sum(totaldue) as 'TotalDue'
FROM sales.sales_order
GROUP BY datepart(yy, orderdate),
datepart(mm, orderdate)

SELECT top 5 *
Database FROM sales.sales_sum_vu
files and WHERE OrderYear >=2007
Data files ORDER BY OrderYear, OrderMonth
Views and
Partition Which of the following is applicable for
68 Single ChoiceApplication Complex Tables above statements? 1
Consider the following statements:

CREATE VIEW hr.male_emp_vu


AS
SELECT empid, empname,
empgender
FROM hr.employees
WHERE empgender = 'M'
WITH CHECK OPTION

Database UPDATE hr.male_emp_vu


files and SET empgender = 'F'
Data files WHERE empid = 1001
Views and
Partition What is the outcome of the satements
69 Single ChoiceApplication Complex Tables as above? 1

Consider the following statements:

CREATE VIEW credit_card_vu


AS
SELECT creditcardid, cardtype,
cardno, expmonth, expyear
FROM sales.creditcard

Database UPDATE credit_card_vu


files and set expyear = expyear + 1
Data files WHERE expyear <= 2004
Views and
Partition What is the outcome of the above
70 Single ChoiceApplication Complex Tables statements? 1

Consider the following SELECT


statement:

SELECT territoryid, sum(totaldue)


FROM sales.salesorder
GROUP BY territoryid
Database ORDER BY territoryid
files and
Data files In case the same SELECT statement
Views and can be exactly achieved by using a
Partition VIEW, which of the following VIEW
71 Single ChoiceApplication Complex Tables definition will be correct? 1

Assume there is a new table 'emp'


created with columns as empid,
empname, empdob, empaddress

The following statements are issued


for creating indexes:

CREATE [CLUSTERED] INDEX idx1


ON emp(empname)
CREATE [CLUSTERED] INDEX idx2
ON emp(empdob)

Single Triggers and What is the outcome of the above


72 Choice Application Complex Indexes statements? 1
Assume there is a new table 'emp'
created with columns as empid,
empname, empdob, empaddress

The following statements are issued


for creating indexes:

CREATE INDEX idx1 ON


emp(empname) INCLUDE
CREATE [NONCLUSTERED] INDEX
idx2 ON emp(empdob) [ASC]

Single Triggers and What is the outcome of the above


73 Choice Application Complex Indexes statements? 1

Assume there is a new table 'emp'


created with columns as empid,
empname, empdob, empaddress,
emailid

empid is the primary key for the above


table.
In addition, a clustered index is
created on empdob for the table.

Now, users require faster access to


employee information based on their
unique emailid.

Single Triggers and Which of the following will achieve the


74 Choice Application Complex Indexes requirement? 1

Assume there is a new table 'emp'


created with columns as empid,
empname, empdob, empaddress

The following statement is issued for


creating index:

CREATE INDEX idx1 ON


emp(empname) INCLUDE
empaddress

What is the significance of the


Single Triggers and INCLUDE clause in the above
75 Choice Application Complex Indexes statement? 1

Assume there is an existing table


'emp' with columns as empid,
empname, empdob, empaddress

In addition, a non-clustered index


(idx1) exists on empdob column.

The following statements are issued :

ALTER INDEX idx1 ON emp


DISABLE
DROP INDEX emp.idx1

Single Triggers and What is the final outcome of issuing


76 Choice Application Complex Indexes the above statements? 1
Assume there is an existing table
'emp' with columns as empid,
empname, empdob, empaddress

In addition, a non-clustered index


(idx1) exists on empdob column.

The following statements are issued :

ALTER INDEX idx1 ON emp


DISABLE
DROP INDEX emp.idx1
ALTER INDEX idx1 ON emp
REBUILD

Single Triggers and What is the final outcome of issuing


77 Choice Application Complex Indexes the above statements? 1

Below is a trigger defined :

01 USE master
02 GO
03 CREATE TRIGGER
srv_trg_RestrictNewLogins
04 ON ALL SERVER
05 FOR CREATE_LOGIN
06 AS
07 PRINT 'No login creations without
DBA involvement.'
08 ROLLBACK
09 GO
Single Triggers and
78 Choice Application Complex Indexes What does the above trigger achieve? 1

Assume there is an existing table


'emp' with columns as empid,
empname, empdob, empaddress
In addition, a non-clustered index
(idx1) exists on empdob column.
Transaction processing and updates
happen 24*7 on the 'emp' table.
Index idx1 has become fragmented
and needs to be rebuilt.

Single Triggers and Which of the following will achieve the


79 Choice Application Complex Indexes above? 1
The following trigger is created an a
table called 'authors' that has columns
au_id, au_name,city

CREATE TRIGGER tr_au_upd ON


authors
FOR INSERT, UPDATE AS

IF UPDATE(city)
BEGIN
ROLLBACK TRAN
END
GO

The following statement is executed


on the authors table:

UPDATE authors
SET city = 'MUMBAI'
WHERE au_id = '1001'

Single Triggers and What will be the outcome of the above


80 Choice Application Complex Indexes statement? 1

The following trigger is created an a


table called 'authors' that has columns
au_id, au_name,city

CREATE TRIGGER tr_au_upd ON


authors
FOR INSERT, UPDATE AS

IF UPDATE(city)
BEGIN
ROLLBACK TRAN
END
GO

The following statement is executed


on the authors table:

INSERT authors(au_id, au_name,city)


VALUES (1001, 'PRAKASH',
'MUMBAI'')

Single Triggers and What will be the outcome of the above


81 Choice Application Complex Indexes statement? 1
The following trigger is created an a
table called 'authors' that has columns
au_id, au_name,city

CREATE TRIGGER tr_au_upd ON


authors
FOR INSERT, UPDATE AS

IF UPDATE(city)
BEGIN
ROLLBACK TRAN
END
GO

The following statement is executed


on the authors table:

INSERT authors(au_id, au_name)


VALUES (1001, 'PRAKASH')

Single Triggers and What will be the outcome of the above


82 Choice Application Complex Indexes statement? 1

The following trigger is created an a


table called 'authors' that has columns
au_id, au_name,city

CREATE TRIGGER tr_au_upd ON


authors
FOR UPDATE AS

IF UPDATE(city)
BEGIN
ROLLBACK TRAN
END
GO

The following statement is executed


on the authors table:

INSERT authors(au_id, au_name)


VALUES (1001, 'PRAKASH')

Single Triggers and What will be the outcome of the above


83 Choice Application Complex Indexes statement? 1
The following trigger is created an a
table called 'authors' that has columns
au_id, au_name,city

CREATE TRIGGER tr_au_upd ON


authors
INSTEAD OF UPDATE AS
PRINT 'Trigger output row updated'
GO

The following statements are


executed on the authors table:

INSERT authors(au_id, au_name)


VALUES (1001, 'Rajeev')
UPDATE authors SET au_name =
'Raghav' WHERE au_id = 1001
GO

SELECT au_id, au_name WHERE


au_id =1001
GO

Single Triggers and What will be the outcome of the above


84 Choice Application Complex Indexes SELECT statement? 1

The following trigger is created an a


table called 'authors' that has columns
au_id, au_name,city

CREATE TRIGGER tr_au_upd ON


authors
INSTEAD OF UPDATE AS
IF @@ROWCOUNT = 0 RETURN
UPDATE authors SET au_name =
'Raman' WHERE au_id = 1001
GO

The following statements are


executed on the authors table:

INSERT authors(au_id, au_name)


VALUES (1001, 'Rajeev')
UPDATE authors SET au_name =
'Raghav' WHERE au_id = 1001
GO

SELECT au_id, au_name WHERE


au_id =1001
GO

Single Triggers and What will be the outcome of the above


85 Choice Application Complex Indexes SELECT statement? 1
The following trigger is scoped at
database level:

CREATE TRIGGER tr_table_audit


ON DATABASE
FOR CREATE_TABLE,
ALTER_TABLE, DROP_TABLE
AS
ROLLBACK
GO

The following statement is isused on


table 'titles' in the database

ALTER TABLE titles ADD new_col


INT NULL
ALTER TABLE titles DROP
COLUMN new_col

Single Triggers and What is the final outcome of issuing


86 Choice Application Complex Indexes the ALTER statements? 1

The following trigger is created -

CREATE TRIGGER tr_index_audit


ON DATABASE
FOR CREATE_INDEX,
ALTER_TABLE, DROP_INDEX
AS
DECLARE @EventData XML
SET @EventData = EVENTDATA()
SELECT @EventData.Query (''
data(/EVENT_INSTANCE/PostTime )''
)
GO

The following statement is issued on


table 'titles' in the database(titles table
has columns titleid, titlename)

CREATE CLUSTERED INDEX idx1


on titles(titlename)

Single Triggers and What is the final outcome of issuing


87 Choice Application Complex Indexes the CREATE statement? 1

Consider the following scenario:

There are two base tables created in a


database. A view is created that joins
columns from the two base tables.
It is required to update specific
columns picked from both the tables
using the view created.

Single Triggers and Which of the following will achieve the


88 Choice Application Complex Indexes above task successfully? 1
Consider the following scenario:

Table 'dept' holds information about


departments like deptid, deptname,
location
deptid is the primary key

Table 'emp' holds information about


employees like empid, name, deptid,
dateofbirth
deptid is the foreign key referencing
the primary key deptid of table dept.

In case a department is closed, the


department row needs to be deleted
from 'dept' table. Since foreign key
constraint exists, the department row
cannot be deleted if there are any
employees in that department.

To overcome the above, an AFTER


TRIGGER was created on the 'dept'
table with code to delete the individual
employee rows based on the deptid.

Which of the following is the final


outcome of issuing a DELETE
Single Triggers and statement for a deptid in the 'dept'
89 Choice Application Complex Indexes table? 1

Consider the following scenario:

Four triggers are defined for some


operations on a table.
The order of firing are defined as
under:

sp_settriggerorder tr_1, FIRST,


'UPDATE'
sp_settriggerorder tr_2, NONE,
'UPDATE'
sp_settriggerorder tr_3, LAST,
'UPDATE'
sp_settriggerorder tr_4, NONE,
'UPDATE'
sp_settriggerorder tr_5, NONE,
'INSERT'

Which of the following are valid


combination of firing order for above
Multiple Triggers and triggers in case an update operation
90 Choice Application Complex Indexes takes place on the table?(Choose 2) 2
There are two tables - 'jobs' table and
'employees' table. Both have an
AFTER trigger defined on them.

There is an UPDATE trigger on


'employees' table.
The UPDATE trigger on 'jobs' table
updates the 'employees' table.

The following statement is issued:


EXEC sp_configure 'nested triggers' ,
0

What will be the outcome in case an


Single Triggers and UPDATE statement is issued on the
91 Choice Application Complex Indexes 'jobs' table? 1

92 Single ChoiceKnowledge Easy Transactions and


We XML
identify
Support
a transaction
in SQL Server
__________. 1

Which of the following applies to SQL


93 Single ChoiceKnowledge Easy Transactions and
Server
XMLtransaction?
Support in SQL Server 1
Which of the following denotes
Transaction Control command in
94 Single ChoiceKnowledge Easy Transactions and
SQL?XML Support in SQL Server 1
Which of the following command is
used to undo the current transaction in
95 Single ChoiceKnowledge Easy Transactions and
SQLXML
Server?
Support in SQL Server 1

Which of the following is the Highest


96 Single ChoiceKnowledge Easy Transactions and
isolation
XML level
Support
in SQL
in SQL
Server
Server
2005? 1

Which of the following we can use to


identify the number of active
97 Single ChoiceKnowledge Easy Transactions and
transactions
XML Support
for current
in SQLconnection?
Server 1
Which of the following is used to
locate specific content and elements
98 Single ChoiceKnowledge Easy Transactions and
within
XMLan Support
XML document?
in SQL Server 1

XML columns can only have one


primary XML index defined.
How many maximum secondary
99 Single ChoiceKnowledge Easy Transactions and
indices
XMLcan
Support
be defined?
in SQL Server 1
Which of the following is NOT a valid
100 Single ChoiceComprehension
Average Transactions and
Replication
XML Support
type? in SQL Server 1
Which of the following command is
used to view the XML indexes used in
101 Single ChoiceComprehension
Average Transactions and
the database?
XML Support in SQL Server 1

Which of the following fixed server


102 Single ChoiceApplication Average Sql Server 2005
roles
- overview
can manage linked servers? 1
You need to perform these tasks:

01 Create and assign a MANAGER


role to Blake and Clark
02 Grant CREATE TABLE and
CREATE VIEW privileges to Blake
and Clark

Which of the following set of SQL


statements achieves the desired
103 Single ChoiceApplication Complex Sql Server 2005
results?
- overview 1

Which of the following SQL statement


create a sequence SE with starting
104 Single ChoiceApplication Complex Sql Server 2005
value
- overview
as 30 and in increments of 20? 1

There is a project allocation table


Implementin which has the following structure:
g Data EmpNum int, ProjNum int, AllocDate
integrity,Sub DateTime, ReleaseDate DateTime
queries and EmpNum and ProjNum form the
Joins & T- composite primary key and we want to
SQL define aPrimary Key constraint with
enhancemen those columns.
Single ts and Choose a valid statement for the
105 Choice Application Average functions above scenario. 1

Implementin The HR database in a company has


g Data EMPLOYEE and DEPARTMENT
integrity,Sub tables.
queries and Dept_id, the primary key of
Joins & T- DEPARTMENT table, is defined as a
SQL foreign key in the EMPLOYEE table
enhancemen with ON DELETE CASCADE option
Single ts and What happens when a department is
106 Choice Application Average functions deleted in the DEPARTMENT table? 1

The HR database in a company has


Implementin EMPLOYEE and DEPARTMENT
g Data tables.
integrity,Sub Dept_id, the primary key of
queries and DEPARTMENT table, is defined as a
Joins & T- foreign key in the EMPLOYEE table
SQL What happens when a department,
enhancemen with no associated EMPLOYEE
Single ts and records, is deleted in the
107 Choice Application Average functions DEPARTMENT table? 1

Implementin The HR database in a company has


g Data EMPLOYEE and DEPARTMENT
integrity,Sub tables.
queries and Dept_id, the primary key of
Joins & T- DEPARTMENT table, is defined as a
SQL NULL column and a foreign key in
enhancemen EMPLOYEE table.
Single ts and What happens when a department is
108 Choice Application Average functions deleted in the DEPARTMENT table? 1
Consider the following table
(ORDERS)

OrderNum Amount ODATE


CustNum
3001 250 03-oct-94
1007
3003 200 03-oct-94
1001
3002 300 03-oct-94
1004
3005 200 04-oct-94
1001
3004 200 04-oct-94
1003

What will be the Row_Number for


Implementin CustNum of 1007 in the following
g Data query?
integrity,Sub select CustNum, sum(Amount),
queries and ROW_NUMBER () OVER (order by
Joins & T- sum(Amount) DESC) as
SQL Row_Number
enhancemen from ORDERS group by CustNum
Single ts and order by sum(Amount) desc
109 Choice Application Complex functions 1

Consider the following table


(ORDERS)

OrderNum Amount ODATE


CustNum
3001 300 03-oct-94
1007
3003 200 03-oct-94
1001
3002 300 03-oct-94
1004
3005 200 04-oct-94
1001
3004 200 04-oct-94
1003
Implementin
g Data What will be the Rank for CustNum of
integrity,Sub 1003 in the following query?
queries and select CustNum, sum(Amount),
Joins & T- RANK () OVER (order by
SQL sum(Amount) DESC) as Rank
enhancemen from ORDERS group by CustNum
Single ts and order by sum(Amount) desc
110 Choice Application Complex functions 1
Consider the following table
(ORDERS)

OrderNum Amount ODATE


CustNum
3001 300 03-oct-94
1007
3003 200 03-oct-94
1001
3002 300 03-oct-94
1004
3005 200 04-oct-94
1001
3004 200 04-oct-94
1003

Implementin What will be the Dense_Rank for


g Data CustNum of 1003 in the following
integrity,Sub query?
queries and select CustNum, sum(Amount),
Joins & T- DENSE_RANK () OVER (order by
SQL sum(Amount) DESC) as Dense_Rank
enhancemen from ORDERS group by CustNum
Single ts and order by sum(Amount) desc
111 Choice Application Complex functions 1

Consider a table 'employees' and a


stored procedure 'sp_process'

The following statements are


executed:

sp_process
Stored SELECT * from employees
procedures
Single and What is the outcome of above
112 Choice Application Average Functions execution? 1

Consider the following statements:

CREATE PROC myproc

@parm1 int, @parm2 int, @parm3 int


AS
----processing done here
RETURN

The above PROC is executed twice


as below:
1) EXEC myproc @parm1 = 4, 5, 6
2) EXEC myproc 4, @parm2 = 5,
Stored @parm3 = 6
procedures
Single and What is the outcome of executing as
113 Choice Application Average Functions above? 1
To run stored procedures using CLR
in SQL Server 2005, you will have to
Stored run a script against your database.
procedures
Single and Which of the following gives the
114 Choice Application Average Functions correct script to be run? 1

Consider the following scenario:

A company ABC has many stored


procedures each one querying
customer database using multiple
conditions.
The DBA thinks that having too many
stored procedures is bad for
maintenance and recommends to
reduce the number of procs.
Stored
procedures Which of the following will be a
Single and solution to the above
115 Choice Application Average Functions recommendation? 1

Consider the following stored


procedures:

CREATE proc main_proc


AS
exec sub_proc1
exec sub_proc2
return
go

CREATE proc sub_proc1


AS
exec sub_proc2
go

CREATE proc sub_proc2


AS
return
Stored
procedures How many times will the proc
Single and sub_proc2 get executed upon invoking
116 Choice Application Average Functions EXEC main_proc? 1
Consider the following stored
procedure:

CREATE PROCEDURE
HumanResources.usp_DeleteCandida
te
(
@CandidateID INT
)
AS
-- Execute the DELETE statement.
DELETE FROM
HumanResources.JobCandidate
WHERE JobCandidateID =
@CandidateID;
--------missing line---------
BEGIN
-- Return 99 to the calling
program to indicate failure.
PRINT N'An error occurred
deleting the candidate information.';
RETURN 99;
END
ELSE
BEGIN
-- Return 0 to the calling program
to indicate success.
PRINT N'The job candidate has
been deleted.';
RETURN 0;
END;
GO
Stored
procedures Which of the following is the correct
Single and statement that can be fitted in the ---
117 Choice Application Average Functions missing line -----? 1

Consider the following statement:

CREATE PROC create_other_proc as


EXEC('CREATE PROC get_au_name
as
Select au_name from authors
Stored RETURN')
procedures
Single and What is the outcome of the above
118 Choice Application Average Functions when create_other_proc is executed? 1

Consider a table 'employees' and a


stored procedure 'sp_process'

The following statements are


executed:

SELECT * from employees


Stored sp_process
procedures
Single and What is the outcome of the above
119 Choice Application Average Functions execution? 1
Consider a table 'employees' and a
stored procedure 'sp_process'

The following statements are


executed:

SELECT * from employees


Stored EXEC sp_process
procedures
Single and What is the outcome of the above
120 Choice Application Average Functions execution? 1

Consider the following stored


procedure creation:

CREATE proc sp_create_staff


AS
EXEC sp_use_jobs

It so happens that the user missed


creating the stored procedure
Stored sp_use_jobs in the database.
procedures
Single and What will be the outcome of the create
121 Choice Application Average Functions procedure sp_create_staff as above? 1

Consider the following statements:

CREATE PROC myproc @parm1 int


= 100, @parm2 int = 200, @parm3 int
= 300
AS
----processing done here
RETURN

The above PROC is executed twice


as below:
1) EXEC myproc
2) EXEC myproc @parm1 =
Stored DEFAULT, @parm2 = 5, @parm3 = 6
procedures
Single and What are the value of parameters
122 Choice Application Complex Functions passed to myproc in both the cases? 1

Consider the following :

CREATE proc advance_range


(@low money, @high money)
WITH RECOMPILE
AS
SELECT * FROM dbo.titles
where advance between @low and
@high
RETURN

Stored Which of the following are valid ways


procedures of executing the above proc in case
Multiple and recompilation of query plan is required
123 Choice Application Complex Functions before executing?(Choose 2) 2
Consider the following :

DECLARE @avg1 money,


DECLARE @avg2 money,
DECLARE @avg3 money

SELECT @avg1 =
dbo.averagebookprice('computers')
SET @avg2 =
dbo.averagebookprice('computers')
EXEC @avg2 =
dbo.averagebookprice 'computers'

SELECT @avg1 as avg1, @avg2 as


avg2, @avg3 as avg3
GO

Assume that averagebookprice is a


user defined scalar function that
Stored returns a value of 100.09 for
procedures 'computers'
Single and which of the following is a correct
124 Choice Application Complex Functions statement? 1

Consider the following :

DECLARE @avg1 money,

SET @avg1 =
averagebookprice('computers')

SELECT @avg1 as avg1

GO

Assume that averagebookprice is a


user defined scalar function that
Stored returns a value of 100.09 for
procedures 'computers'
Single and which of the following is a correct
125 Choice Application Complex Functions statement? 1

Consider the following example of a


multi-statement table valued function
in which some important statements
are missing:

CREATE FUNCTION
averagepricebytype(@ price money =
0.0
RETURNS @table
AS
Insert @table
SELECT type, avg(isnull(price,
0)) as avg_price
FROM titles
GROUP BY type
HAVING avg(isnull(price, 0)
> @price
RETURN
Stored
procedures Which of the following explains the
Multiple and missing statements to be included in
126 Choice Application Complex Functions above?(Choose 2) 2
Consider the following example of a
multi-statement table valued function:

CREATE FUNCTION
averagepricebytype(@ price money =
0.0
RETURNS @table table(type
varchar(12) null, avg_price money
null)
AS
BEGIN
Iinsert @table
SELECT type, avg(isnull(price,
0)) as avg_price
FROM titles
GROUP BY type
HAVING avg(isnull(price, 0)
> @price
RETURN
Stored END
procedures
Single and Which of the following example is
127 Choice Application Complex Functions correct to invoke the above function? 1

Consider the following example of a


multi-statement table valued function:

CREATE FUNCTION
averagepricebytype(@ price money =
0.0
RETURNS @table table(type
varchar(12) null, avg_price money
null)
with schemabinding
AS
BEGIN
Iinsert @table
SELECT type, avg(isnull(price,
0)) as avg_price
FROM titles
GROUP BY type
HAVING avg(isnull(price, 0)
> @price
RETURN
END

The following command is issued on


the table 'titles' that is used in the
function above:
ALTER table titles alter column price
Stored smallmoney null
procedures
Single and Which of the following happens upon
128 Choice Application Complex Functions executing the ALTER command? 1
Consider the following Function:

CREATE FUNCTION
striptime(@datetimeval datetime)

RETURNS datetime
WITH RETURNS NULL ON NULL
INPUT
AS
BEGIN
DECLARE @dateval datetime
SELECT @dateval =
convert(char(10), isnull@datetimeval),
getdate()), 110)
RETURN @dateval
END
Stored
procedures Which of the following happens when
Single and the above function is invoked with
129 Choice Application Complex Functions NULL input? 1

Consider the following function


creation:

CREATE FUNCTION
dbo.getonlydate()
RETURNS datetime
as
BEGIN
DECLARE @date datetime
SET @date = dbo.striptime(getdate())
RETURN @date
END

Assume 'striptime' is another function


Stored already created.
procedures
Single and Which of the following statement is
130 Choice Application Complex Functions correct for the above create function? 1

Consider the following function


creation:

CREATE FUNCTION
dbo.getonlydate()
RETURNS datetime
as
BEGIN
DECLARE @date datetime
SET @date = getdate()
RETURN @date
END
Stored
procedures Which of the following happens due to
Single and the use of non-deterministic function
131 Choice Application Complex Functions getdate() in the above UDF? 1
Consider the following function
creation:

CREATE FUNCTION
dbo.getonlydate()
RETURNS datetime
as
BEGIN
DECLARE @date datetime,
@randomdata int
SET @date = getdate()
SET @randomdata = rand()
RETURN @date
END

Stored Which of the following happens due to


procedures the use of non-deterministic functions
Single and getdate() and rand() in the above
132 Choice Application Complex Functions UDF? 1

Consider the following function:

CREATE FUNCTION
averagepricebytype(@price money =
0.0)
RETURNS TABLE
AS
RETURN (SELECT type,
avg(isnull(price, 0)) as avg_price
FROM titles
GROUP BY type
HAVING avg(isnull(price, 0))
Stored > @price)
procedures
Single and Which of the following statement is
133 Choice Application Complex Functions correct for the function above? 1
Consider the following sequence of
commands for functions:

CREATE FUNCTION
averagepricebytype(@price money =
0.0)
RETURNS TABLE
AS
RETURN (SELECT type,
avg(isnull(price, 0)) as avg_price
FROM titles
GROUP BY type
HAVING avg(isnull(price, 0))
> @price)

ALTER FUNCTION
averagepricebytype(@price money =
0.0)
RETURNS @table table(type
varchar(12) null, avg_price money
null)
AS
BEGIN
Iinsert @table
SELECT type, avg(isnull(price,
0)) as avg_price
FROM titles
GROUP BY type
HAVING avg(isnull(price, 0))
> @price
RETURN
Stored END
procedures
Single and Which of the following statement is
134 Choice Application Complex Functions correct for the above statements? 1
Consider the following sequence of
commands for functions:

CREATE FUNCTION
averagepricebytype(@price money =
0.0)
RETURNS TABLE
AS
RETURN (SELECT type,
avg(isnull(price, 0)) as avg_price
FROM titles
GROUP BY type
HAVING avg(isnull(price, 0))
> @price)

ALTER FUNCTION
averagepricebytype(@price money =
0.0)
RETURNS TABLE
AS
RETURN (SELECT type,
avg(isnull(price, 0)) as avg_price
FROM titles
GROUP BY type
HAVING avg(isnull(price, 0))
< @price)
Stored
procedures
Single and Which of the following statement is
135 Choice Application Complex Functions correct for the above statements? 1

Consider the creation of following


stored procedure:

CREATE proc check_user_who


WITH EXECUTE AS 'Sunil'
AS
SELECT user_name() as 'User name
applicable'
GO

The following statements are


executed:

SELECT user_name() as 'User name


applicable'
EXEC check_user_who
Stored
procedures What is the result of SELECT in
Single and sequence when the above statements
136 Choice Application Complex Functions are executed? 1
Consider the following stored
procedure creation:

CREATE proc sp_check_authors


AS
SELECT au_id, au_name,
au_last_title FROM authors
WHERE au_id > 1001
GO

It so happens that the authors table is


dropped and no longer exists in the
Stored database.
procedures What will be the outcome of the create
Single and procedure sp_check_authors as
137 Choice Application Complex Functions above? 1

Consider the following stored


procedure creation:

CREATE proc sp_check_authors


AS
SELECT au_id, au_name,
au_last_title FROM authors
WHERE au_id > 1001
GO

It so happens that the authors table is


dropped and no longer exists in the
database.

Now the following statement is issued


EXEC sp_check_authors
Stored GO
procedures
Single and What will be the outcome of the above
138 Choice Application Complex Functions create and execution statements? 1
Consider the following stored
procedure creation:

CREATE proc sp_check_authors


AS
BEGIN
SELECT au_id, au_name,
au_last_title FROM authors
WHERE au_id > 1001
RETURN
GO

Now the following statements are


issued :

EXEC sp_helptext sp_check_authors


GO

SELECT definition FROM


sys.sql_modules
WHERE object_id =
object_id('sp_check_authors')
GO

SELECT object_definition
(object_id('dbo.sp_check_authors'))
Stored GO
procedures
Single and What will be the outcome of the above
139 Choice Application Complex Functions statements issued? 1

Consider the following statements:

ALTER PROC insert_items @item_id


char(4),
@item_name varchar(40)
as
BEGIN TRY
INSERT INTO comp1.dbo.itemmaster
(item_id, item_name)
VALUES(@item_id, @item_name)
print ‘New Item added’
END TRY
BEGIN CATCH
exec error_handler
RETURN -101
END CATCH
RETURN 0

What is the return code if the following


Stored statement is executed?
procedures
Single and EXEC insert_items ‘ABCDEFGH’,
140 Choice Application Complex Functions ‘Gear Assembly’ 1
Consider the following statements:

ALTER PROC insert_items @item_id


char(4),
@item_name varchar(40)
as
BEGIN TRY
INSERT INTO comp1.dbo.itemmaster
(item_id, item_name)
VALUES(@item_id, @item_name)
print ‘New Item added’
END TRY
BEGIN CATCH
exec error_handler
RETURN -101
END CATCH
RETURN 0

What is the return code if the following


statement is executed and the
Stored operation is successful?
procedures
Single and EXEC insert_items ‘9951’, ‘Gear
141 Choice Application Complex Functions Assembly’ 1

Consider the following statements:

CREATE PROC sales_till_date


@title varchar(100), @ytd_sales int
OUTPUT
AS
SELECT @ytd_sales = ytd_sales
FROM titles
where title = @title
RETURN

The above proc is executed as


follows:

DECLARE @sales_upto_today int


EXEC sales_till_date 'My experiments
with truth', @sales_upto_today
Print 'Sales this year until today :' +
CONVERT(varchar(10),
Stored @sales_upto_today
procedures
Single and What is the outcome of executing as
142 Choice Application Complex Functions above? 1
Consider the following statements:

Assume table 'titles' exists with


following books only:

Life without fear


My experiments with truth
Gone with the wind

CREATE PROC ytd_sales2 @title


varchar(80)
AS
IF NOT EXISTS (SELECT * FROM
titles WHERE title = @title)
RETURN -111
SELECT ytd_sales
from titles where title = @title
RETURN
GO

The above PROC is executed as


follows:

DECLARE @status INT


EXEC @status = ytd_sales2 'Life
without fear'
IF @status = -111
PRINT 'No book with that name
found'
GO
EXEC @status = ytd_sales2
'Undefeated'
GO
EXEC @status = ytd_sales2 'Gone
with the wind'
IF @status = -111
PRINT 'No book with that name
found'
GO
Stored
procedures How many times the message 'No
Single and book with that name found'' will be
143 Choice Application Complex Functions displayed for the above scenario? 1
Consider the following statements:

CREATE PROC pub_test


AS
SELECT pub_id, pub_name, city,
statecd
into ##temp
from publishers
where statecd in ('MH', 'AP', 'TN')

SELECT pub_id, pub_name, city,


statecd
into #temp
from publishers
where statecd in ('MH', 'AP', 'TN')
GO

The following sequence of execution


statements are made:

EXEC pub_test
GO
SELECT * from ##temp -----1
SELECT * from #temp -----2

EXEC pub_test
GO
SELECT * from ##temp ------3
Stored
procedures What is the correct sequence of
Single and outcome on executing the SELECT
144 Choice Application Complex Functions statements marked 1,2 3 as above? 1

Consider the following statements:

CREATE PROC pub_test


AS
SELECT pub_id, pub_name, city,
statecd
into ##temp
from publishers
where statecd in ('MH', 'AP', 'TN')

SELECT pub_id, pub_name, city,


statecd
into #temp
from publishers
where statecd in ('MH', 'AP', 'TN')
GO

The following sequence of execution


statements are made:

EXEC pub_test
GO
SELECT * from ##temp ------- 1
SELECT * from #temp ------- 2
DROP table ##temp
EXEC pub_test
GO
SELECT * from ##temp -------- 3
Stored
procedures What is the correct sequence of
Single and outcome on executing the SELECT
145 Choice Application Complex Functions statements marked 1,2,3 as above? 1
Consider the following scenario
example:

CREATE PROC find_books_by_type


@typelist varchar(8000)
AS
EXEC('select title_id, title =
substring(title, 1, 40), type, price
FROM titles where type in ('+
@typelist + ') order by type, title_id')
GO

set quoted_identifier off

The stored procedure is executed as


below:
EXEC find_books_by_type "'business',
'mod_cook', 'trad_cook'"
GO
Stored
procedures Which of the following are correct
Multiple and statements for the above scenario?
146 Choice Application Complex Functions (Choose 2) 2

Consider the following Stored


procedures created:

CREATE PROC
get_titles_data_by_price(@flag tinyint,
@value money)
AS
select * from titles where price =
@value
GO
CREATE PROC
get_titles_data_by_advance(@flag
tinyint, @value money)
AS
select * from titles where advance =
@value
GO
CREATE PROC get_titles_data(@flag
tinyint, @value money)
AS
if @flag = 1
exec get_titles_data_by_price
@value
else
exec get_titles_data_by_advance
@value
Stored
procedures Which of the following stored
Single and procedure is functionally equivalent to
147 Choice Application Complex Functions the above set of stored procedures? 1
Consider the following statements:

CREATE PROC myproc @parm1


int1, @parm2 int, @parm3 int
AS
----processing done here
RETURN

The above PROC is executed twice


as below:
1) EXEC myproc
Stored 2) EXEC myproc @parm1 = 6
procedures
Single and What is the outcome of executing the
148 Choice Application Complex Functions above ? 1

Consider the following stored


procedures:

CREATE proc main_proc


AS
exec sub_proc1
exec sub_proc3
exec sub_proc2
return
go

CREATE proc sub_proc1


AS
exec sub_proc2
go

CREATE proc sub_proc2


AS
exec proc sub_proc3
return

CREATE proc sub_proc3


AS
exec sub_proc1
Stored return
procedures
Single and What will be the outcome upon
149 Choice Application Complex Functions invoking EXEC main_proc? 1
Consider the following stored
procedure:

CREATE PROCEDURE
SelectByIdList
(@productIds xml
)
AS
DECLARE @Products TABLE (ID int)
INSERT INTO @Products (ID)
SELECT
ParamValues.ID.value('.','VARCHAR(
20)')
FROM @productIds.nodes('/Products/
id')
as ParamValues(ID)
SELECT * FROM ProductsINNER
JOIN @Products pON
Products.ProductID = p.ID
Stored
procedures Which of the following is the correct
Single and way to call the above stored
150 Choice Application Complex Functions procedure and pass values? 1

Which of the following is the Highest


151 Single ChoiceKnowledge Easy Transactions and
isolation
XML level
Support
in SQL
in SQL
Server
Server
2005? 1

Transactions
and XML Distributed queries allow you to collect
Single Support in and manipulate data from
152 Choice Knowledge Easy SQL Server __________________________ 1

You are writing a distributed query to


Transactions query data from another SQL Server
and XML database.
Single Comprehensi Support in What is the fully qualified naming
153 Choice on Average SQL Server convention? 1

Transactions You are writing a distributed query to


and XML query data from an Access database.
Single Comprehensi Support in What is the fully qualified naming
154 Choice on Average SQL Server convention? 1

A distributed transaction is
encompassing three different
database serves. At the end of
prepare phase in a two-phase commit,
two servers reported successful
Transactions prepare while one reported failure to
and XML prepare.
Single Comprehensi Support in How would the transaction manager
155 Choice on Average SQL Server respond? 1

Consider the following scenario.


Your SQL server has a link to an
Oracle database Ora_db running on
Transactions Ora_linked_server. The schema
and XML definition of Ora_db has undergone a
Single Comprehensi Support in change.
156 Choice on Average SQL Server What will be the impact? 1

Transactions
and XML Which of the following the datasource
Single Comprehensi Support in must conform to in order to be a
157 Choice on Average SQL Server linkedserver? 1
Transactions
and XML
Single Comprehensi Support in Which of the following is the use of
158 Choice on Average SQL Server sp_linkedservers command? 1

Transactions
and XML For which of the following is a two-
Single Comprehensi Support in phase commit, consisting of prepare
159 Choice on Average SQL Server and commit used? 1

Transactions
and XML
Single Comprehensi Support in Which of the following is correct for a
160 Choice on Average SQL Server shared lock? 1

A transaction attempting to modify


Transactions data on a row or page on which a
and XML shared lock is placed can acquire an
Comprehensi Support in exclusive lock on the resource.
161 True or False on Average SQL Server State True or False. 1

Transactions
and XML When a SELECT * command is
Single Comprehensi Support in executed on a table, when is the
162 Choice on Average SQL Server shared lock on the first row released? 1

A transaction attempting to modify


Transactions data on a row or page on which a
and XML shared lock is placed can acquire an
Comprehensi Support in update lock on the resource.
163 True or False on Average SQL Server State True or False. 1

Consider the following scenario:

A Table 'book' has the following


records
id title
--- ------
2 Catch-22
3 Roses in December
4 My experiments with Truth

Assume a default isolation level of


'READ COMMITTED' for the following
commands.

User1 has issued the following


commands
BEGIN TRAN
SELECT title FROM book where id =
2;

User2 has now issued the following


commands
Transactions SELECT title FROM book where id =
and XML 2;
Single Support in
164 Choice Application Easy SQL Server What will be the outcome? 1
Consider the following scenario:

A Table 'book' has the following


records
id title
--- ------
2 Catch-22
3 Roses in December
4 My experiments with Truth

Assume a default isolation level of


'READ COMMITTED' for the following
commands.

User1 has issued the following


commands
BEGIN TRAN
SELECT title FROM book WITH
(UPDLOCK) where id = 2;

User2 has now issued the following


commands
Transactions SELECT title FROM book where id =
and XML 2;
Single Support in
165 Choice Application Easy SQL Server What will be the outcome? 1

Consider the following scenario:

A Table 'book' has the following


records
id title
--- ------
2 Catch-22
3 Roses in December
4 My experiments with Truth

Assume a default isolation level of


'READ COMMITTED' for the following
commands.

User1 has issued the following


commands
BEGIN TRAN
SELECT title FROM book WITH
(UPDLOCK) where id = 2;

User2 has now issued the following


commands
Transactions SELECT title FROM book WITH
and XML (UPDLOCK) where id = 2;
Single Support in
166 Choice Application Easy SQL Server What will be the outcome? 1
Consider the following scenario:

A Table 'book' has the following


records
id title
--- ------
2 Catch-22
3 Roses in December
4 My experiments with Truth

Assume a default isolation level of


'READ COMMITTED' for the following
commands.

User1 has issued the following


commands
BEGIN TRAN
SELECT title FROM book WITH
(UPDLOCK) where id = 2;

User2 has now issued the following


commands
Transactions SELECT title FROM book WITH
and XML (UPDLOCK) where id = 3;
Single Support in
167 Choice Application Easy SQL Server What will be the outcome? 1

Consider the following scenario:

A Table 'book' has the following


records
id title
--- ------
2 Catch-22
3 Roses in December
4 My experiments with Truth

Assume a default isolation level of


'READ COMMITTED' for the following
commands.

User1 has issued the following


commands
BEGIN TRAN
SELECT title FROM book where id =
2;

User2 has now issued the following


commands
UPDATE book SET title = 'Roses in
Transactions December, Second edition' WHERE id
and XML =2
Single Support in
168 Choice Application Easy SQL Server What will be the outcome? 1
Consider the following scenario:

A Table 'book' has the following


records
id title
--- ------
2 Catch-22
3 Roses in December
4 My experiments with Truth

Assume a default isolation level of


'READ COMMITTED' for the following
commands.

User1 has issued the following


commands
BEGIN TRAN
UPDATE book SET title = 'Roses in
December, Second edition' WHERE id
=2

User2 has now issued the following


commands
Transactions SELECT title FROM book WHERE id
and XML =2
Single Support in
169 Choice Application Easy SQL Server What will be the outcome? 1

Consider the following scenario:

A Table 'book' has the following


records
id title
--- ------
2 Catch-22
3 Roses in December
4 My experiments with Truth

Assume a default isolation level of


'READ COMMITTED' for the following
commands.

User1 has issued the following


commands
BEGIN TRAN
SELECT title FROM book WITH
(UPDLOCK, HOLDLOCK) WHERE id
=2

User2 has now issued the following


commands
Transactions SELECT title FROM book WHERE id
and XML =2
Single Support in
170 Choice Application Easy SQL Server What will be the outcome? 1
Consider the following scenario:

A Table 'book' has the following


records
id title
--- ------
2 Catch-22
3 Roses in December
4 My experiments with Truth

Assume a default isolation level of


'READ COMMITTED' for the following
commands.

User1 has issued the following


commands
BEGIN TRAN
SELECT title FROM book WITH
(UPDLOCK, HOLDLOCK)

User2 has now issued the following


commands
INSERT INTO book VALUES(5,
Transactions 'Harry Potter and the Half-blood
and XML Prince')
Single Support in
171 Choice Application Easy SQL Server What will be the outcome? 1

Consider the following scenario:

A Table 'book' has the following


records
id title
--- ------
2 Catch-22
3 Roses in December
4 My experiments with Truth

Assume a default isolation level of


'READ COMMITTED' for the following
commands.

User1 has issued the following


commands
BEGIN TRAN
SELECT title FROM book WITH
(UPDLOCK, HOLDLOCK) WHERE
title like '%experiments%'

User2 has now issued the following


commands
INSERT INTO book VALUES(6,
Transactions 'Harry Potter and the Half-blood
and XML Prince')
Single Support in
172 Choice Application Easy SQL Server What will be the outcome? 1
Consider the following scenario:

A Table 'book' has the following


records
id title
--- ------
2 Catch-22
3 Roses in December
4 My experiments with Truth

Assume a default isolation level of


'READ COMMITTED' for the following
commands.

User1 has issued the following


commands
BEGIN TRAN
DELETE FROM book WHERE title
like '%experiments%'

User2 has now issued the following


commands
INSERT INTO book VALUES(6,
Transactions 'Harry Potter and the Half-blood
and XML Prince')
Single Support in
173 Choice Application Easy SQL Server What will be the outcome? 1

Consider the following scenario:

A Table 'book' has the following


records
id title
--- ------
2 Catch-22
3 Roses in December
4 My experiments with Truth

Assume a Isolation level of


'READ_COMMITTED_SNAPSHOT'
for the following commands.

User1 has issued the following


commands
BEGIN TRAN
UPDATE book SET title = 'Roses in
December, Second edition' WHERE
id = 2

User2 has now issued the following


commands
Transactions SELECT title FROM book WHERE id
and XML =2
Single Support in
174 Choice Application Average SQL Server What will be the outcome? 1
Consider the following code:

BEGIN TRAN
DELETE FROM TABLE1
BEGIN TRAN
INSERT INTO TABLE2
COMMIT
UPDATE TABLE3
Transactions COMMIT
and XML
Single Support in If the update to table3 failed, what will
175 Choice Application Average SQL Server be the outcome? 1

The PLAYER table contains these


columns :

id int(9)
name varchar(2)
manager_id int(9)

In this instance, managers are also


players whom you need to display as
a list.

Evaluate these TWO SQL statements:

Statement 1:
SELECT p.name,m.name
FROM player p,player m
Implementin WHERE m.manager_id=p.id;
g Data
integrity,Sub Statement 2:
queries and SELECT p.name,m.name
Joins & T- FROM player p,player m
SQL WHERE m.manager_id=p.id;
enhancemen
Single ts and Which of the following is applicable for
176 Choice Application Complex functions the above statements? 1

The new Isolation level in SQL Server


Transactions 2005 wherein the values that are
and XML accessed remain the same till the
Single Support in transaction is Committed or Rolled
177 Choice Knowledge Easy SQL Server back is called ____________. 1

Consider the following construct:

WHILE (1=1)
BEGIN
PRINT 'I am here in one'
IF 1 = 1
BEGIN
PRINT 'I am here in two'
BREAK
END
ELSE
BEGIN
CONTINUE
END
END
Control flow
Single constructs, What is the outcome of executing the
178 Choice Application Average Cursors above? 1
Consider the following construct:

WHILE (1=1)
BEGIN
PRINT 'I am here in one'
IF 1 = 1
BEGIN
PRINT 'I am here in two'
END
ELSE
BEGIN
CONTINUE
END
END

Control flow How many times the message 'I am


Single constructs, here in one' will be printed on
179 Choice Application Average Cursors executing above? 1

Consider the following statements as


part of a stored procedure:

WAITFOR DELAY '02:00:22'


BEGIN
EXEC sp_process_total_one
WAITFOR TIME '02:00:22'
BEGIN
EXEC sp_process_total_two
END

Control flow Supposing the above procedure is is


Single constructs, run exactly at midnight, what is the
180 Choice Application Average Cursors expected outcome? 1

Consider the following cursor


processing:

DECLARE authors_cursor
FORWARD_ONLY FOR
SELECT au_lname, au_fname FROM
authors
ORDER BY au_lname, au_fname

OPEN authors_cursor

FETCH FIRST FROM authors_cursor


FETCH RELATIVE 3 FROM
authors_cursor
FETCH RELATIVE -2 FROM
authors_cursor

CLOSE authors_cursor
DEALLOCATE authors_cursor

(Assume that authors table has 200


author profiles)
Control flow
Single constructs, What is the outcome of executing the
181 Choice Application Average Cursors above cursor statements? 1
Consider the following cursor
processing:

DECLARE authors_cursor SCROLL


FOR
SELECT au_lname, au_fname FROM
authors
ORDER BY au_lname, au_fname

OPEN authors_cursor

FETCH NEXT FROM authors_cursor


FETCH ABSOLUTE 20 FROM
authors_cursor
FETCH RELATIVE 3 FROM
authors_cursor
FETCH RELATIVE -7 FROM
authors_cursor
FETCH FIRST FROM authors_cursor

CLOSE authors_cursor
DEALLOCATE authors_cursor

(Assume that authors table has 200


author profiles)

Control flow How many unique rows are retrieved


Single constructs, upon executing the above cursor
182 Choice Application Average Cursors statements? 1

Consider the following cursor


processing statements:

DECLARE Employee_Cursor
CURSOR READ_ONLY FOR
SELECT LastName, FirstName,
status
FROM dbo.Employees
WHERE LastName like 'B%'

OPEN Employee_Cursor
FETCH NEXT FROM
Employee_Cursor
PRINT @@FETCH_STATUS
WHILE @@FETCH_STATUS = 0
BEGIN
FETCH NEXT FROM
Employee_Cursor
PRINT @@FETCH_STATUS
END

CLOSE Employee_Cursor
DEALLOCATE Employee_Cursor

(Assume that the Employees table has


500 rows of employee data)

Control flow What is the value of


Single constructs, @@FETCH_STATUS printed in the
183 Choice Application Average Cursors last print statement as per above? 1
Consider the following cursor
processing statements:

DECLARE @cba CURSOR


DECLARE abc CURSOR GLOBAL
SCROLL FOR
SELECT * FROM authors

SET @cba = abc

OPEN abc

FETCH NEXT FROM @cba


FETCH NEXT FROM abc
FETCH NEXT FROM @cba

CLOSE @cba
DEALLOCATE abc

In case the authors table had 100


Control flow author profiles, how many authors will
Single constructs, get retrieved as per above
184 Choice Application Average Cursors processing? 1

Consider the following cursor


processing statements:

DECLARE Employee_Cursor
CURSOR FAST_FORWARD FOR
SELECT LastName, FirstName,
status
FROM dbo.Employees
WHERE LastName like 'B%'
FOR UPDATE

OPEN Employee_Cursor
FETCH NEXT FROM
Employee_Cursor
WHILE @@FETCH_STATUS = 0
BEGIN
DELETE Employees WHERE
current of Employee_Cursor
FETCH NEXT FROM
Employee_Cursor
END

CLOSE Employee_Cursor
DEALLOCATE Employee_Cursor

(Assume that the Employees table has


500 rows of employee data)
Control flow
Single constructs, What is the outcome of the above
185 Choice Application Average Cursors cursor processing? 1

Consider the following statements:

WHILE (1=1)
BEGIN
WAITFOR TIME '01:00'
EXEC sp_update_stats
RAISERROR('Statistics updated for
database',1,1) WITH LOG
Control flow END
Single constructs,
186 Choice Application Average Cursors What is the outcome of the above? 1
Consider the following cursor
processing statements:

DECLARE authors_cursor CURSOR


FOR
SELECT au_id, au_fname, au_lname
FROM authors
WHERE state = 'UT'
ORDER BY au_id

OPEN authors_cursor

IF @@CURSOR_ROWS = 0
END

FETCH NEXT FROM authors_cursor

IF @@FETCH_STATUS = -1
PRINT 'NO ROWS FOUND'
END
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT 'ATLEAST ONE ROW
FOUND '
FETCH NEXT FROM
authors_cursor
END
END
CLOSE authors_cursor
DEALLOCATE authors_cursor

What is the message that gets printed


Control flow in case the authors table does not
Multiple constructs, have any rows satisfying the given
187 Choice Application Average Cursors condition? 2

Consider the following cursor


processing statements:

DECLARE @cba CURSOR


DECLARE abc CURSOR GLOBAL
SCROLL FOR
SELECT * FROM authors
OPEN abc
FETCH NEXT FROM @cba
FETCH NEXT FROM abc
FETCH NEXT FROM @cba

CLOSE @cba
DEALLOCATE abc

In case the authors table had 100


Control flow author profiles, how many authors will
Single constructs, get retrieved as per above
188 Choice Application Average Cursors processing? 1
Consider the following statements:

SELECT deptid,
name,
groupname,
CASE
WHEN groupname =
'Marketing' THEN 'Room 1'
WHEN groupname =
'Human Resources' THEN 'Room 2'
WHEN groupname =
'Production' THEN 'Room 3'
ELSE 'Room 4'
END
FROM hr.department
Control flow
Single constructs, Which of the following is correct
189 Choice Application Average Cursors equivalent to the above? 1
Consider the following scenario:

A proc is created as follows:

CREATE PROC cursor_proc @cursor


CURSOR VARYING OUTPUT
AS
DECLARE curs1 CURSOR GLOBAL
FOR SELECT cast(title as
varchar(30)) as title, pubdate from
titles
set @cursor = curs1
open curs1
return
go

Now the following statements are


executed:

DECLARE @curs CURSOR


EXEC cursor_proc @cursor = @curs
output
fetch curs1
fetch @curs
close curs1
deallocate curs1
fetch @curs
open @curs
go
Control flow
Single constructs, What is the outcome of the last fetch
190 Choice Application Average Cursors and open statements in above? 1
Consider the following scenario:

A proc is created as follows:

CREATE PROC cursor_proc @cursor


CURSOR VARYING OUTPUT
AS
DECLARE curs1 CURSOR GLOBAL
FOR SELECT cast(title as
varchar(30)) as title, pubdate from
titles
set @cursor = curs1
open curs1
return
go

Now the following statements are


executed:

DECLARE @curs CURSOR


EXEC cursor_proc @cursor = @curs
output
fetch curs1
fetch @curs
close curs1
deallocate curs1
fetch @curs
open @curs
fetch @curs
close @curs
deallocate @curs
open @curs
go

Control flow What is the outcome of the last fetch


Single constructs, and open statements in the above
191 Choice Application Average Cursors statements? 1
Consider the following scenario:

A proc is created as follows:

CREATE PROC cursor_proc @cursor


CURSOR VARYING OUTPUT
AS
DECLARE curs1 CURSOR GLOBAL
FOR SELECT cast(title as
varchar(30)) as title, pubdate from
titles
set @cursor = curs1
open curs1
return
go

Now the following statements are


executed:

DECLARE @curs CURSOR


EXEC cursor_proc @cursor = @curs
output
fetch curs1
fetch @curs
close curs1
deallocate curs1
deallocate curs
fetch @curs
open @curs
go

Control flow What is the outcome of the last fetch


Single constructs, and open statements in the above
192 Choice Application Average Cursors statements? 1
Consider the following scenario:

A proc is created as follows:

CREATE PROC cursor_proc @cursor


CURSOR VARYING OUTPUT
AS
DECLARE curs1 CURSOR GLOBAL
FOR SELECT cast(title as
varchar(30)) as title, pubdate from
titles
set @cursor = curs1
open curs1
return
go

Now the following statements are


executed:

DECLARE @curs CURSOR


EXEC cursor_proc @cursor = @curs
output
fetch curs1
fetch @curs
close curs1
deallocate curs1
fetch @curs
open @curs
fetch @curs
close @curs
open @curs
go

Control flow What is the outcome of the last fetch


Single constructs, and open statements in the above
193 Choice Application Average Cursors statements? 1

Consider the following cursor


processing:

DECLARE authors_cursor
FAST_FORWARD FOR
SELECT au_lname, au_fname FROM
authors
ORDER BY au_lname, au_fname

OPEN authors_cursor

FETCH NEXT FROM authors_cursor


FETCH NEXT FROM authors_cursor
FETCH NEXT FROM authors_cursor
FETCH NEXT FROM authors_cursor
CLOSE authors_cursor
DEALLOCATE authors_cursor

(Assume that authors table has 200


author profiles)
Control flow
Single constructs, What is the outcome of executing the
194 Choice Application Average Cursors above cursor statements? 1
Consider the following cursor
processing:

DECLARE authors_cursor
FAST_FORWARD FOR
SELECT au_lname, au_fname FROM
authors
ORDER BY au_lname, au_fname

OPEN authors_cursor

FETCH NEXT FROM authors_cursor


FETCH RELATIVE 7 FROM
authors_cursor
FETCH ABSOLUTE 5 FROM
authors_cursor
FETCH LAST FROM authors_cursor
CLOSE authors_cursor
DEALLOCATE authors_cursor

(Assume that authors table has 200


author profiles)
Control flow
Single constructs, What is the outcome of executing the
195 Choice Application Average Cursors above cursor statements? 1

Consider the following temporary


stored procedure:
CREATE PROCEDURE #use_temp
AS
SELECT 1/0
RETURN @@ERROR
GO

The following statements are


executed in a procedure:

IF NOT EXISTS(SELECT productid


FROM production.product WHERE
color = 'yellow' )
BEGIN
RETURN
END

SELECT productid FROM


production.product WHERE color =
'yellow'
DECLARE @ErrorCode INT
EXEC @ErrorCode INT = #use_temp
PRINT @ErrorCode

Control flow Assuming that there is no product with


Single constructs, yellow color, what is the final outcome
196 Choice Application Complex Cursors of executing as above? 1
Consider the following temporary
stored procedure:
CREATE PROCEDURE #use_temp
AS
SELECT 1/0
RETURN @@ERROR
GO

The following statements are


executed in a procedure:

IF NOT EXISTS(SELECT productid


FROM production.product WHERE
color = 'yellow' )
BEGIN
RETURN
END

SELECT productid FROM


production.product WHERE color =
'red'
DECLARE @ErrorCode INT
EXEC @ErrorCode INT = #use_temp
PRINT @ErrorCode

Assuming that the database has


Control flow products with red, yellow and blue
Single constructs, colors, what is the final outcome of
197 Choice Application Complex Cursors executing as above? 1
Consider the following statements:

SELECT deptid,
name,
groupname,
CASE groupname
WHEN 'Marketing' THEN
'Room 1'
WHEN 'Human Resources'
THEN 'Room 2'
WHEN 'Production' THEN
'Room 3'
ELSE 'Room 4'
END
FROM hr.department
Control flow
Single constructs, Which of the following is correct
198 Choice Application Complex Cursors equivalent to the above? 1
Consider the following cursor
processing:

The following procedures are created:

CREATE PROC sp_two


AS
SET NO COUNT ON
FETCH C1
RETURN
GO

CREATE PROC sp_one


AS
SET NO COUNT ON
DECLARE CURSOR C1 GLOBAL
FOR
SELECT titleid, type from titles
OPEN C1
FETCH C1
EXEC sp_two
CLOSE C1
DEALLOCATE C1
GO
(Assume that titles table has 100 book
titles)
Control flow
Single constructs, How many book titles are retrieved
199 Choice Application Complex Cursors when proc sp_one is executed? 1

Consider the following cursor


processing:

The following procedures are created:

CREATE PROC sp_two


AS
SET NO COUNT ON
FETCH C1
RETURN
GO

CREATE PROC sp_one


AS
SET NO COUNT ON
DECLARE CURSOR C1 LOCAL
FOR
SELECT titleid, type from titles
OPEN C1
FETCH C1
EXEC sp_two
CLOSE C1
DEALLOCATE C1
GO
(Assume that titles table has 100 book
titles)
Control flow
Multiple constructs, What are the possible outcomes when
200 Choice Application Complex Cursors proc sp_one is executed?(Choose 2) 2
Consider the following cursor
processing:

The following procedures are created:

CREATE PROC sp_two


AS
SET NO COUNT ON
DECLARE CURSOR C1 LOCAL FOR
SELECT au_id, au_name form
authors
OPEN C1
FETCH C1
CLOSE C1
DEALLOCATE C1
RETURN
GO

CREATE PROC sp_one


AS
SET NO COUNT ON
DECLARE CURSOR C1 LOCAL
FOR
SELECT titleid, type from titles
OPEN C1
FETCH C1
EXEC sp_two
CLOSE C1
DEALLOCATE C1
GO
Control flow
Single constructs, What is the possible outcome when
201 Choice Application Complex Cursors proc sp_one is executed? 1
Consider the following cursor
processing:

The following procedures are created:

CREATE PROC sp_two


AS
SET NO COUNT ON
DECLARE CURSOR C2 GOBAL FOR
SELECT au_id, au_name form
authors
OPEN C2
RETURN
GO

CREATE PROC sp_one


AS
SET NO COUNT ON
DECLARE CURSOR C1 LOCAL
FOR
SELECT titleid, type from titles
OPEN C1
FETCH C1
EXEC sp_two
FETCH C2
CLOSE C1
DEALLOCATE C1
CLOSE C2
DEALLOCATE C2
RETURN
GO
(Assume that titles table has 100 book
titles and authors table has 200 author
Control flow profiles)
Single constructs, What is the possible outcome when
202 Choice Application Complex Cursors proc sp_one is executed? 1
Consider the following cursor
processing:

The following procedures are created:

CREATE PROC sp_two


AS
SET NO COUNT ON
DECLARE CURSOR C2 GOBAL FOR
SELECT au_id, au_name form
authors
OPEN C2
RETURN
GO

CREATE PROC sp_one


AS
SET NO COUNT ON
DECLARE CURSOR C1 LOCAL
FOR
SELECT titleid, type from titles
OPEN C1
FETCH C1
EXEC sp_two
FETCH C2
CLOSE C1
DEALLOCATE C1
RETURN
GO

(Assume that titles table has 100 book


titles and authors table has 200 author
profiles)

The above is executed as follows:


EXEC sp_one
GO
FETCH C2
GO
Control flow
Single constructs, What is the possible outcome of the
203 Choice Application Complex Cursors above execution? 1
Consider the following cursor
processing statements:

DECLARE @au_lname varchar(40),


@au_fname varchar(20)

DECLARE authors_cursor CURSOR


[FAST_FORWARD] FOR
SELECT au_lname, au_fname FROM
authors
WHERE au_lname LIKE 'B%'

OPEN authors_cursor

FETCH NEXT FROM authors_cursor


INTO @au_lname, @au_fname

WHILE @@FETCH_STATUS = 0
BEGIN
PRINT 'Author: ' + @au_fname + ' '
+ @au_lname
FETCH NEXT FROM
authors_cursor
INTO @au_lname, @au_fname
END

CLOSE authors_cursor
DEALLOCATE authors_cursor
GO

In case the authors table has authors


with following entries

au_lname au_fname

BHARAT IYER
ASHISH MALHOTRA
BIDYUT THAKUR
ANISH MATRE
BALA SUBRAMANIAN

Control flow How many author names would have


Single constructs, got printed at the end as per the
204 Choice Application Complex Cursors cursor processing above? 1
Consider the following cursor
processing statements:

DECLARE authors_cursor CURSOR


FOR
SELECT au_id, au_fname, au_lname
FROM authors
WHERE state = 'UT'
ORDER BY au_id

OPEN authors_cursor

IF @@CURSOR_ROWS = 0
BEGIN
CLOSE authors_cursor
DEALLOCATE authors_cursor
RETURN
END

FETCH NEXT FROM authors_cursor

IF @@FETCH_STATUS = - 1
PRINT ' NO ROWS FOUND '
ELSE
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT 'ATLEAST ONE ROW
FOUND '
FETCH NEXT FROM
authors_cursor
END
END
CLOSE authors_cursor
DEALLOCATE authors_cursor

What is the message that gets printed


Control flow in case the authors table does not
Single constructs, have any rows satisfying the given
205 Choice Application Complex Cursors condition? 1

Sham has to convert the rows of the


'Employee' table to a xml file, adhering
to the following rules :

1.The values in each row should be


the property of the 'row' tag
2.Create another file in which the
column name must be the tag name
for each value
3.Root tag must have the name as
'ROOT' and each and every row must
start with the tag name 'ROW'
4.Root tag must have a property
specifying the xml Namespace
Transactions
and XML Per Rule 1, which of the following
Single Comprehensi Support in Centric method should Sham use to
206 Choice on Average SQL Server create the file? 1
Sham has to convert the rows of the
'Employee' table to a xml file, adhering
to the following rules :

1.The values in each row should be


the property of the 'row' tag
2.Create another file in which the
column name must be the tag name
for each value
3.Root tag must have the name as
'ROOT' and each and every row must
start with the tag name 'ROW'
4.Root tag must have a property
Transactions specifying the xml Namespace
and XML
Single Comprehensi Support in Per the Rule 2, which of the following
207 Choice on Average SQL Server Query should he use to create a file? 1

Sham has to convert the rows of the


'Employee' table to a xml file, adhering
to the following rules :

1.The values in each row should be


the property of the 'row' tag
2.Create another file in which the
column name must be the tag name
for each value
3.Root tag must have the name as
'ROOT' and each and every row must
start with the tag name 'ROW'
4.Root tag must have a property
Transactions specifying the xml Namespace
and XML
Single Comprehensi Support in Which of the following query is the
208 Choice on Average SQL Server correct one for the rule 3? 1

Sham has to convert the rows of the


'Employee' table to a xml file, adhering
to the following rules :

1.The values in each row should be


the property of the 'row' tag
2.Create another file in which the
column name must be the tag name
for each value
3.Root tag must have the name as
'ROOT' and each and every row must
start with the tag name 'ROW'
4.Root tag must have a property
Transactions specifying the xml Namespace
and XML
Single Comprehensi Support in Which clause helps in attaining the
209 Choice on Average SQL Server Xml namespace in the Root tag? 1

Arun is retrieving Employee photos


and storing them in a binary format.
He then wants to convert that Binary
format into a string format as a value
Transactions inside a Xml File.
and XML
Single Comprehensi Support in Which of the following Encoding
210 Choice on Average SQL Server methods will you suggest? 1
Consider the following two statements:

Staement 1: FOR XML RAW - does


not support converting to XML file
from a Join Query
Statement 2: FOR XML AUTO -
supports converting to XML file from a
Transactions join Query
and XML
Single Comprehensi Support in Which of the following is applicable for
211 Choice on Average SQL Server the above statements? 1

Transactions Which of the folllowng FOR XML


and XML clause helps in controling the
Single Comprehensi Support in hierarchy of the xml result set
212 Choice on Average SQL Server generated? 1

Consider the following statement:

With xmlnamespaces
(
'http://schemas.microsoft.com as act
)
SELECT
NAME,ADDRESS.query('//act:email')
FROM PERSONAL_DETAILS
FOR XML
RAW('contactaddress'),ROOT('contac
tDetails)

Transactions Query() method expects the pro-long


and XML part and body part when it is used
Comprehensi Support in along with 'WITH' statement .
213 True or False on Average SQL Server State TRUE or FALSE. 1

Transactions
and XML Which of the following methods()
Single Comprehensi Support in decompose the xml into a logical table
214 Choice on Average SQL Server similar to OPENXML? 1

Vinay is working on a module where


he has to insert the Employee details
into a table named 'EMPDETAILS'.
While working on the module, he
inserted the Employee name 'ram'
first time and "RAM' as Second time.

Rajiv is converting the data inserted


by Vinay into a XML file and finds that
there are two different tags with the
same name.
While searching the name in the xml
file using the Query() method, he was
Transactions not able to get both the tags.
and XML
Single Support in What could be the reason for Rajiv not
215 Choice Application Average SQL Server being able to get it? 1
Consider the following scenario:

Jothi is working on a Xml File, which


contains a tag named Email and its
value is 'DUMMY@DUMMY.COM'.
She needs to find out the tag which
contains the value as
'DUMMY@DUMMY.COM' and
Transactions replace it with another value.
and XML
Single Support in Which of the following clause helps
216 Choice Application Average SQL Server her in replacing the Value? 1

Consider the following statement:

SELECT * FROM SALES S


JOIN
PRODUCT P ON
P.PRODUCT_ID=S.PRODUCT_ID
JOIN
PURCHASE PU ON
PU.PRODUCT_ID=P.PRODUCT_ID
Transactions FOR XML RAW('Child'),ELEMENTS
and XML
Single Support in What is the outcome of the above
217 Choice Application Average SQL Server statement? 1

Consider the following statement:

SELECT * FROM SALES


JOIN
PURCHASE on
PURCHASE.ID=SALES.ID
Transactions FOR XML AUTO('ROW'),ELEMENTS
and XML
Single Support in What will be the outcome of the above
218 Choice Application Average SQL Server statement? 1

Consider the following statement:

SELECT * FROM SALES


ORDER BY PRODUCT
FOR XML RAW('ROW'),Elements
Transactions XSINIL, ROOT('ROOT'),xmldata
and XML
Single Support in Which of the following gives the error
219 Choice Application Average SQL Server in the above statement? 1
Consider the following table:

SALES ID Contents
1 table
5 Chair
Here is the XML result from a Query.
<ROOT xmlns:xsi="http://www.w3.org/
2001/XMLSchema-instance">
<CHILD>
<id>1</id>
<contents>table</contents>
</CHILD>
<CHILD>
<id>5</id>
<contents>chair</contents>
</CHILD>
Transactions </ROOT>
and XML
Single Support in Identify the Query which gave the
220 Choice Application Average SQL Server above Result? 1

Consider the following statement:

SELECT * FROM SALES


JOIN
PURCHASE on
PURCHASE.ID=SALES.ID
FOR XML RAW('CHILD'),Elements
XSINIL,
Transactions ROOT('ROOT'),XMLSCHEMA
and XML
Single Support in Which of the following is applicable for
221 Choice Application Average SQL Server the above query? 1

Consider the following statement:

1.SELECT TOP 1 ID,CONTENTS


FROM SALES
2.JOIN
3.PURCHASE on
PURCHASE.ID=SALES.ID
4.FOR XML RAW('CHILD'),Elements
XSINIL,
ROOT('ROOT'),XMLSCHEMA
5.BINARY

Transactions Which of the following can be added


and XML in the 5th line from the following which
Single Support in helps in Encoding the Binary data that
222 Choice Application Average SQL Server is Supported in SQL Server 2005? 1
Consider the following item table and
the statement:

ITEM ID CONTENTS
1 Table
2 Chair

Select 123 as Tag, 0 as Parent,


Contents as[contentsTable!123!
contents]
from item
Transactions for xml EXPLICIT
and XML
Single Support in What is the result of the above
223 Choice Application Average SQL Server statement? 1

Compare the following two


statements:

1.SELECT * FROM ITEM


FOR XML
PATH('PRODUCT'),ROOT('PRODUC
TITEM')

2.SELECT * FROM ITEM


FOR XML
RAW('PRODUCT'),ELEMENTS,ROO
T('PRODUCTITEM')
Transactions
and XML Choose the correct option based on
Single Support in the output from the above two
224 Choice Application Average SQL Server statements. 1

Consider the following statement:

SELECT * FROM ITEM


FOR XML
PATH('PRODUCT'),XSINIL,ROOT('P
Transactions RODUCTITEM')
and XML
Single Support in What is the outcome of the above
225 Choice Application Average SQL Server statement? 1

Transactions Which of the following helps in taking


and XML a Column 'CONTENTS' value as a
Single Support in inner string in between the
226 Choice Application Average SQL Server PRODUCTITEMS tag in FOR XML ? 1
Consider the following ITEM table and
the statement:

ID CONTENTS
1 Table
2 Chair

SELECT CONTENTS 'processing-


instruction(CONT)',
(select ID 'data()'from item for xml
path('')) 'work/worker/@id'
FROM ITEM
FOR XML
PATH('PRODUCTITEMS'),ROOT('PR
Transactions ODUCT')
and XML
Single Support in What is the result of the above
227 Choice Application Average SQL Server statement? 1

Transactions Which of the following statement helps


and XML in taking a Column 'CONTENTS'
Single Support in value as a Comment which is prefixed
228 Choice Application Average SQL Server with 'Comments:' in FOR XML ? 1

Consider the following output :

<PRODUCT>
<PRODUCTITEMS>
<?CONT table?>
<work>
<worker id="1 2 3 4" />
</work>
</PRODUCTITEMS>

Here, the value for ID attribute are


taken from ID column of the Item
Transactions table.
and XML
Single Support in Which of the following node helps us
229 Choice Application Average SQL Server in obtaining it? 1
Consider the following table and the
OUTPUT:
ITEM
ID CONTENTS
1 Table
2 Chair

OUTPUT:

<PRODUCT>
<PRODUCTITEMS>
<ID>1</ID>
<tagname contents="table" />
</PRODUCTITEMS>
<PRODUCTITEMS>
<ID>2</ID>
<tagname contents="chair" />
</PRODUCTITEMS>
</PRODUCT>

Transactions Which of the following helps in placing


and XML the CONTENTS column value as the
Single Support in value of contents attribute of the Tag
230 Choice Application Average SQL Server 'Tagname'? 1

Consider the following statement:

SELECT
address.query('http://schemas.micros
oft.com';
1.LET $pin=600220
2.FOR $pin IN//PIN
3.WHERE
COUNT('/ADDRESS/PIN')>60000
4.ORDER BY
XS:NAME(STRING($ADDRESS/NAM
E)) DESC
RETURN
<PIN>823456
</PIN>
)AS RESULT
FROM CONTACT_DETAILS WHERE
emp_id=10
Transactions
and XML Which of the following iterator or
Single Support in clause is not supported in SQL Server
231 Choice Application Average SQL Server of the above numbered statement? 1

Transactions
and XML
Single Support in Which of the following is NOT
232 Choice Application Average SQL Server supported in MODIFY() method? 1
Consider the following two statements
regarding Query compilation and
optimization:

Statement 1: All the T-SQL


statements that come under the DDL
are Compiled and optimized.
Statement 2: All the T-SQL
statements that come under the DML
Transactions are Compiled and optimized.
and XML
Single Comprehensi Support in Which of the following is applicable for
233 Choice on Average SQL Server the above statements? 1

Consider the following two statements


regarding Query compilation and
optimization:

Statement 1: While Identifying the Join


clause, query optimizer treats INNER
JOIN as two different tables
Statement 2: While Identifying the Join
clause, query optimizer treats SELF
Transactions JOIN as a single table
and XML
Single Comprehensi Support in Which of the following is applicable for
234 Choice on Average SQL Server the above statements? 1

While searching the arguments for


optimization, if the query optimizer
does not find any statistics of index or
column in case of an Inequality
operator (<> or !=), the SQL server
takes the following step(s).

Step1: Sql Server automatically


generates and updates the statistics
for Index or Column.
Step2: Takes the difference between
the total number of rows and the
number of rows for the equality
Transactions operator.
and XML
Single Comprehensi Support in Which of the following is applicable for
235 Choice on Average SQL Server above? 1

Raju is working on a payroll project


and he needs to find the Net pay of
each employee working in the
company for more than 1 year.
He can implement an index on the
employee tenure in the company (i.e.
Transactions current date minus date of joining) and
and XML speed up the query processing.
Comprehensi Support in
236 True or False on Average SQL Server State True or False. 1

Transactions
and XML How does Snapshot isolation differ
Single Comprehensi Support in from Read committed snapshot
237 Choice on Average SQL Server isolation? 1

Transactions
and XML
Single Comprehensi Support in How many isolation levels can be
238 Choice on Average SQL Server active for a user at any point of time? 1
If the same query or stored procedure
Transactions is executed repeatedly, SQL server
and XML may not generate execution plan each
Comprehensi Support in time.
239 True or False on Average SQL Server State True or False. 1

Transactions For which of the following situation


and XML SQL server may determine that an
Single Comprehensi Support in execution plan needs to be
240 Choice on Average SQL Server recompiled? 1

Transactions
and XML
Single Support in Which of the following SELECT
241 Choice Application Complex SQL Server statement will execute the fastest? 1
Consider the following sequence of
operations from two users :

User 1 -
SET TRANSACTION ISOLATION
LEVEL SNAPSHOT
go
begin tran
select * from book
go
Id Title
--- ------
2 Catch-22
3 Roses in December

User 2 -
BEGIN TRAN
update book set Title = ‘Roses in
December Edition 2’
where id = 3
go

User 1 -

update book set Title = ‘My


Experiments with Truth’
Transactions where id = 3
and XML go
Single Support in
242 Choice Application Complex SQL Server What will be the outcome? 1

Consider the following T-SQL


statement :

SELECT * FROM EMP_DETAILS


INNER JOIN
EMP_SALARYDETAILS
ON
EMP_DETAILS.EMP_ID=EMP_SALA
RYDETAILS.EMPID
WHERE EMPID=1001 OR EMPID
=1002

Identify the order of optimization of the


Transactions following clauses
and XML a.INNER JOIN
Single Support in b.WHERE
243 Choice Application Complex SQL Server c.OR 1
You are creating a procedure that will
update two tables within a transaction.
The code looks similar to the
following:

1 BEGIN TRANSACTION
2
3 BEGIN TRY
4 UPDATE . . .
5
6 END TRY
7
8 BEGIN CATCH
9 IF . . .
10
11 END CATCH
12
Transactions
and XML Give the line number, where the
Single Support in ROLLBACK statement would normally
244 Choice Application Complex SQL Server be placed? 1

You are creating a procedure that will


update two tables within a transaction.
The code looks similar to the
following:

1 BEGIN TRANSACTION
2
3 BEGIN TRY
4 UPDATE . . .
5
6 END TRY
7
8 BEGIN CATCH
9 IF . . .
10
11 END CATCH
12
Transactions
and XML Give the line number, where the
Single Support in COMMIT statement would normally be
245 Choice Application Complex SQL Server placed? 1
Consider the following stored
procedure:

1 begin tran
2 update account set balance =
balance - 1000 where
account_number = 123
3 if @@error != 0
4 begin
5 rollback tran
6 return
7 end
8 update account set balance =
balance + 1000 where
account_number = 456
9 if @@error != 0
10 begin
11 rollback tran
12 return
13 end
Transactions 14 commit tran
and XML
Single Support in If error code in line 9 is 12, what will
246 Choice Application Complex SQL Server be the outcome? 1

Consider the following stored


procedure -

1 begin tran add_book


2 insert book (id, name) values (2,
‘SQL for dummies’)
3 if @@error = 50000
4 begin
5 rollback tran add_book
6 return
7 end
8 save tran keep_the_first
09 insert book (id, name) values (3,
‘20 immutable laws of leadership’)
10 if @@error = 50000
11 begin
12 rollback tran keep_the_first
13 end
Transactions 14 commit tran
and XML
Single Support in If the error code returned by line 10 is
247 Choice Application Complex SQL Server 50000, what will be the outcome? 1
Consider the following stored
procedure -

1 begin tran add_book


2 insert book (id, name) values (2,
‘SQL for dummies’)
3 if @@error = 50000
4 begin
5 rollback tran add_book
6 return
7 end
8 save tran keep_the_first
09 insert book (id, name) values (3,
‘20 immutable laws of leadership’)
10 if @@error = 50000
11 begin
12 rollback tran keep_the_first
13 end
Transactions 14 commit tran
and XML
Single Support in If the error code returned by line 3 is
248 Choice Application Complex SQL Server 50000, what will be the outcome? 1

Consider the following statement:

CREATE PROCEDURE
SP_GETSTATE
(
@CNO INT,
@CNAME VARCHAR(50)
)
AS
BEGIN
BEGIN
SELECT @CNAME=CNAME FROM
COUNTRY WHERE CNO=@CNO
END
SELECT S.SNAME FROM
STATE S
INNER JOIN
COUNTRY C
ON C.CNO=S.CNO WHERE
S.CNO=@CNO
FOR XML
RAW('STATE'),ELEMENTS
XSINIL,ROOT(@CNAME)
END

If you pass the @CNO value as CNO


Transactions of 'INDIA' ,
and XML what will be the output of the above
Single Support in stored procedure while
249 Choice Application Complex SQL Server creating/executing the procedure? 1
Consider the following statement:

DECLARE @XMLVAR XML


SET @XMLVAR='
<INDIA>
<STATES>
<STATE SNO="1" SNAME="TN" />
</STATES>
<STATES>
<STATE SNO="2" SNAME="AP" />
</STATES>
<STATES>
<STATE SNO="3" SNAME="UP" />
</STATES>
</INDIA>'
SELECT

XMLTABLE.XMLCOLUMN.query('SN
AME') AS node,

XMLTABLE.XMLCOLUMN.VALUE('S
TATE[1]/@SNO','CHAR(1)') AS
STATE_CODE
FROM
@XMLVAR.nodes('/INDIA/STATES')
Transactions AS XMLTABLE(xmlcolumn)
and XML
Single Support in What is the result of the above
250 Choice Application Complex SQL Server statement? 1
TRUE FALSE Y

Both Both
Statements 1 Statements 1
and 2 are and 2 are
Statement 1 is true, 2 is false Y Statement 1 is false, 2 is true true false

Once a data
file is added There is no
to a limit to the
database, it number of
cannot be filegroups
moved to that can be
Filegroups apply only to data A data file can spread across another created for a
files and not log files Y multiple filegroups. filegroup Y database

Choose a
common The path
location or specified for
directory to locating the
keep the database
Data and log files should be database files should
placed on the same disk files to keep exist before
Database files should have drive to maximise things creating a
sufficient space for growth Y performance organised Y database Y

Both Both
Statements 1 Statements 1
and 2 are and 2 are
Statement 1 is true, 2 is false Statement 1 is false, 2 is true true Y false

The
procedure It can be
remains executed
active even only by the
It is automatically deleted after the connection
It can be accessed by when the connection is connection is that created
multiple connections closed Y closed it Y
If a sub
procedure
referenced a
temporary
Global table created
temporary externally, a
tables are temporary
not available table with the
if the user same name
session in and structure
Local temporary tables Global temporary tables which they has to exist
created in a stored created in a stored were created at the time
procedure are automatically procedure are unavailable disconnects the stored
dropped when the stored immediately after the stored from the SQL procedure is
procedure exits. Y procedure exits Server. Y created.

Statement 2
and 3 are Statements 2
Statement 1 is true, 2 and 3 true, 1 is is true, 1 and
Statement 1,2 and 3 are true are false false Y 3 are false

All the
available
These are system
generally stored
The stored procedure more useful procedures
The stored procedure name resides in a Resource to end users are fully
begins with sp_. Y database Y than DBAs. documented

Both Both
Statements 1 Statements 1
and 2 are and 2 are
Statement 1 is true, 2 is false Statement 1 is false, 2 is true Y true false

Constant
Local variables Function Y values Expression Y
Multi-
statement
table valued None of the
Scalar function Y In-line table valued function function listed options

Both Both
Statements 1 Statements 1
and 2 are and 2 are
Statement 1 is true, 2 is false Statement 1 is false, 2 is true true Y false

A CLR-
integrated
A CLR- stored
integrated procedure
A standard T-SQL stored A T-SQL stored procedure stored that uses a
procedure that uses a cursor procedure Y cursor

Compile
errors or
object name
resolution
errors that Severity 20
happen or higher
during errors that
Severity 20 or higher errors Errors with severity 10 or deferred results in
that do not result in closing less that are warnings and name closing of a
of a connection Y informational messages resolution connection
Declare statements to define EXECUTE statements that
variables and cursors that call an extended stored All of the
are local to the function procedure listed options Y

Multi-
statement
table valued None of the
Scalar function In-line table valued function function Y listed options

Automatic Reuse Of
Improved Security Precompiled Execution Execution Y Code

The stored
The stored procedure
procedure has multiple
The stored procedure does The stored procedure has returns no SELECT
not perform update dynamic SQL statements more than a statements
operations on tables, except executed via the EXECUTE single result and uses
against table variables Y statement set Y cursors

Drop the
procedure
Drop the procedure using Modify the using DROP
DROP and re-create a new Create a new procedure with procedure command
one using CREATE the same name using using ALTER and modify
command Y CREATE command command Y using ALTER

Both Both
Statements 1 Statements 1
and 2 are and 2 are
Statement 1 is true, 2 is false Statement 1 is false, 2 is true Y true false

FAST_FOR
STATIC Y DYNAMIC KEYSET WARD

FETCH None of the


FETCH SECOND FETCH ABSOLUTE 2 Y RELATIVE 2 listed options
Both Both
Statements 1 Statements 1
and 2 are and 2 are
Statement 1 is true, 2 is false Statement 1 is false, 2 is true Y true false

Both Both
Statements 1 Statements 1
and 2 are and 2 are
Statement 1 is true, 2 is false Y Statement 1 is false, 2 is true true false

Both Both
Statements 1 Statements 1
and 2 are and 2 are
Statement 1 is true, 2 is false Statement 1 is false, 2 is true true false Y

DEALLOCAT
E CLOSE
FETCH NEXT FROM contact_curs contact_curs
contact_cursor Y OPEN contact_cursor or Y or Y
Local Scroll Y Global Scroll_locks

TRUE Y FALSE

A table
cannot have
an INSTEAD
of trigger and
FOREIGN
KEY
constraint
with
CASCADE
Only one INSTEAD of trigger defined for
INSTEAD trigger does not can be defined for each the same All of the
support recursion action on a given table action listed options Y

FIRST Y NONE Y ANY LAST Y

Coumns that
Columns that are frequently have many
Queries that do not return used in the WHERE clause distinct All of the
large result sets that return exact matches values listed options Y

Defining
Foreign key Defining
Using Stored procedures Y Defining indexes constraints Y views

Allows an
application
program to contains
find specific information
data without about
scanning modifications
Automatically created at the through the carried out in
Smallest unit of data storage time of creating a table entire table Y the database

Under
Master
database in
Under msdb database in Under tempdb database in sysxlogins None of the
sysxlogins tables sysxlogins tables tables Y listed options

TRUE Y FALSE
User Defined
View temp table Type Y Extension

msdb model master tempdb Y

You can
An indexed view is any view The indexed view is a logical create only
that has a clustered index entity and is not materialized one index on
defined on it Y in the database a view Indexed viewsYaid in optmizing performance

GRANT
select ON
GRANT select ON dept TO GRANT QUERY ON dept dept TO None of the
ALL_ USERS TO ALL_USERS PUBLIC; Y listed options

Plain Join
Nested subquery Correlated subquery Y Subquery Subquery

Union Subquery Join Role Y

SELECT INTO Y UNION SUBQUERY JOIN


None of the
IF..ELSE WHILE Y CASE listed options

User Defined Entity


Data Integrity Domain Integrity Y Integrity Integrity

User Defined Entity


Referential Integrity Y Domain Integrity Integrity Integrity

User Defined Entity


Data Integrity Domain Integrity Integrity Integrity Y
Define
Referential
Integrity
constraints
so that data
Create a view on the four Further can be
tables. Create an index on Denormalize the database normalize referenced
the view design if possible Y the table faster
UPDATE
new_employ
ees SET
name =
(SELECT
last_name ||
first_name
FROM
employees
WHERE
employee_id
=180)
WHERE
UPDATE new_employees UPDATE new_employees employee_id
SET name = (Select SET name = (SELECT =(SELECT
last_name || first_name last_name || first_name employee_id
FROM employees Where FROM employees) WHERE FROM new None of the
employee_id =180) Y employee_id = 180; employees) listed options

A subquery A query
cannot should not
A subquery must be put in contain a contain more
A subquery must be the right hand side of the ORDER-BY than one
enclosed in parenthesis comparison operator clause sub-query Y
Increasing
column Modify
Insert Y Changing Column Name Y length Y datatype

Creates four Creates


partitions three
1) for data partitions
before 1993 1) for data of
2) for data of 1993 or prior
Creates four partitions 1993 to 1993
1) for data before 1993 Creates three partitions 3) for data of 2) for data of
2) for data of 1993 1) for data of 1993 1994 1994
3) for data of 1994 2) for data of 1994 4) for data of 3) for data of
4) for data of 1995 or later Y 3) for data of 1995 or later 1995 1995 or later
It retrieves
information
of employees
born on or
It retrieves after March
information 1, 1965 and
of employees who have
It retrieves information of who have been hired
employees born after March It retrieves information of been hired on or after
1, 1965 and who have been employees born after March after february after february
hired after february 1, 2007 Y 1, 1965 1, 2007 1, 2007

IsIndexable IsIndexable
is a property is a property
that returns 0 that returns 0
if an index if an index
IsIndexable is a property that can be can be
returns 1 if the view has IsIndexable is a property that created on created on
atleast one index, and 0 if returns 1 if an index can be the view, and the view, and
there is no index created on created on the view, and 0 if 1 if it is not 1 if it is not
the view it is not indexable. Y indexable. indexable.

UNIQUE
clause in the
CREATE Database
FOR CREATION OF INDEX SCHEMA qualifier for
SCHEMABINDING clause Y clause line each table Y
Adds files to Adds files to
Adds files with new names Adds files to folders filegroups Y database

Select * from
prod.product
_details
Select * from Select * from where
prod.product_details Select * from prod.product unit_of_mea
where unit_of_measure = prod.product_details _details sure = 'KG'
'KG' where unit_of_measure = where OPTION(EX
OPTION(NOEXPAND 'KG' unit_of_mea PAND
VIEWS) OPTION(EXPAND VIEWS) Y sure = 'KG' INDEXES)

Moves the
log file of the
Employee
database to
Modifies the name of the Alters the Employee the root of
Employee database log file database structure the C: drive Y None of the listed options

It is a valid
basic data
It is an error and invalid data It could be an user defined type None of the
type Y data type Y supported listed options

Creates
Customers_p
1 table in
partition
scheme
custPS1 and
column
Creates partitioned view order_dt is
CustPS1 on table Creates Customers_p1 used for None of the
customers_p1 table in file group custPS1 partitioning Y listed options
Creates table
Table1 in
filegroup
userdata_FG
and creates
a clustered
Creates table Table1 in Creates table Table1 in index in
filegroup userdata_FG and filegroup userdata_FG and filegroup
creates a clustered index in creates a clustered index in userindex_F None of the
filegroup userdata_FG default filegroup Y G listed options

ALTER
ALTER COLUMN
COLUMN emp_addres
emp_addres s of TABLE
s of TABLE emp
ALTER TABLE emp ALTER ALTER TABLE emp ALTER emp VARCHAR(4
COLUMN emp_address COLUMN emp_address VARCHAR(4 0) NOT
VARCHAR(40) NULL VARCHAR(40) NOT NULL 0) NULL NULL

ALTER
COLUMN
ALTER TABLE emp ALTER ALTER COLUMN emp.emp_ad
COLUMN emp_address emp_address of TABLE emp dress nchar None of the
nchar NULL Y nchar NULL NULL listed options

ALTER
TABLE emp
ADD
emp.emp_ge
nder char
ALTER TABLE emp ADD ALTER TABLE ADD NOT NULL
emp_gender char NOT emp.emp_gender char NOT AFTER None of the
NULL NULL emp_name listed options Y

ALTER
TABLE emp
ADD AT
END
ALTER TABLE ADD ALTER TABLE emp ADD emp_gender
emp.emp_gender char NOT emp_gender char NOT char NOT None of the
NULL NULL Y NULL listed options
Create fails
because
derived
columns in
SELECT
should have
a name or
Create fails because derived alias Creates an
Creates a simple view columns are not allowed in associated indexed view
successfully. SELECT with it Y successfully.

Create fails
because
ORDER BY
clause is not
Create fails because derived allowed in Creates an
Creates a simple view columns are not allowed in this indexed view
successfully. SELECT statement Y successfully.

Creates a Create fails


simple view because
and retrieves GROUP BY
Creates a simple view, and minimum of clause is not
retrieves maximum of five Create fails because the five records allowed in
records based on the given CREATE statement does not based on the CREATE
criteria Y have ORDER BY clause criteria statement
The
CREATE
statement
goes through
The CREATE statement fails The CREATE and the but UPDATE
because CHECK OPTION is UPDATE statements go statement None of the
invalid for create view through successfully fails Y listed options

The
CREATE
statement
goes through
The CREATE and the but UPDATE
UPDATE statements go statement None of the
The CREATE statement fails through successfully Y fails listed options

CREATE
VIEW
sales_vu AS
SELECT
territoryid,
sum(totaldue
CREATE VIEW sales_vu AS ) 'Totalsales'
SELECT territoryid, CREATE VIEW sales_vu AS FROM
sum(totaldue) 'Totalsales' SELECT territoryid, sales.salesor
FROM sales.salesorder sum(totaldue) 'Totalsales' der
GROUP BY territoryid FROM sales.salesorder GROUP BY None of the
ORDER BY territoryid ORDER BY territoryid territoryid listed options Y

Only one
clustered
index idx2
Two clustered indexes idx1 Only one clustered index will be No index will
and idx2 will be created on idx1 will be created on emp created on be created
emp table table Y emp table on emp table
Creates
Creates clustered
non- index idx1 on
clustered empname
indexes idx1 and non-
on empname clustered
Creates clustered index idx1 and idx2 on index idx2 on
Creates non-clustered on empname and non- empdob, empdob,
indexes idx1 on empname clustered index idx2 on both in both in
and idx2 on empdob, both in empdob, both in ascending ascending descending
descending order order order Y order

This
Create a non requirement
unique cannot be
clustered met by
Create a unique clustered Create a unique non- index on creating
index on emailid clustered index on emailid Y emailid indexes

It includes
empaddress
It concatenates empaddress It creates index values for in the leaf
to empname to form the empname only if address is level pages None of the
index present(not null) of the index Y listed options

The
The index statements
idx1 is end with
The index idx1 is completely The index idx1 is temporarily permanently execution
removed Y disabled disabled error
The
The index statements
idx1 is end with
The index idx1 gets The index idx1 is temporarily permanently execution
recreated disabled disabled error Y

It is a DDL
trigger that
restricts
It is a AFTER DML trigger It is an INSTEAD OF trigger creation of
that restricts addition of new that restricts addition of new new user
users except with DBA users except with DBA logins into a None of the
privileges privileges server Y listed options

Use ALTER
command
and rebuild Rebuild is
Use ALTER command and using not possible
disable the index using Use ALTER command and REBUILD when the
DISABLE clause and rebuild rebuild the index using with ONLINE table is
using REBUILD clause REBUILD clause = ON clause Y updated 24*7
The city for
au_id = 1001
is not
The city for au_id = 1001 is changed in
changed to MUMBAI in The city for au_id = 1001 is the authors None of the
authors table set to NULL in authors table table Y listed options

A new row
for au_id =
1001 is
inserted with
A new row for au_id = 1001 name =
is inserted with name = PRAKASH
PRAKASH and city = No row is added for au_id = and city = None of the
MUMBAI 1001 Y NULL listed options
A new row
for au_id =
1001 is
inserted with
name =
A new row for au_id = 1001 PRAKASH
is inserted with name = No row is added for au_id = and city = None of the
PRAKASH and city = NULL 1001 Y blank listed options

A new row
for au_id =
1001 is
inserted with
name =
A new row for au_id = 1001 PRAKASH
is inserted with name = No row is added for au_id = and city = None of the
PRAKASH and city = NULL Y 1001 blank listed options
Select shows
au_id = 1001
and
Select shows au_id = 1001 Select shows au_id = 1001 au_name as None of the
and au_name = 'Rajeev' Y and au_name = 'Raghav' NULL listed options

Select shows Select shows


au_id = 1001 au_id = 1001
and and
Select shows au_id = 1001 Select shows au_id = 1001 au_name as au_name =
and au_name = 'Rajeev' and au_name = 'Raghav' NULL 'Raman' Y
Creation of
new column
The new column new_col is The new column new_col is new_col on
created and dropped on created on table titles but table titles None of the
table titles drop fails itself fails Y listed options

The
clustered
index idx1 is
created on
The clustered index idx1 is titles table
created on titles table colum colum
titlename and the event- titlename
The clustered index idx1 fails specific information appears without any None of the
to create in the results pane Y notification listed options

Create an
INSTEAD of Create an
UPDATE AFTER
Trigger on Trigger on
the view and the view and
Directly use the UPDATE update update
statement on the view to There is no solution to tables as tables as
update columns from both update the columns from part of trigger part of trigger
the base tables both tables using the view code Y code
The delete
on dept table
fails due to
foreign key
constraint
and no
The further
The employee rows in table department deletions
empgets deleted and the row in dept take place on
department row in dept table The employee rows in emp table alone dept or emp
is then deleted table alone get deleted gets deleted table Y

tr_4, tr_1, tr_1, tr_2,


tr_1 , tr_4, tr_2, tr_3 Y tr_1, tr_5, tr_4, tr_3 tr_2, tr_3 tr_5, tr_3
Both the jobs
Only and
employees employees
Both the employees and jobs table gets tables are
tables are updated Only jobs table gets updated Y updated not updated

by its name by its parameters by its performance by its ACID propertyY

It must be None of the


It must be isolated It must be durable sealed Y listed options

ROLLBACK COMMIT SAVEPOINT All of the listed options


Y

COMMIT ROLLBACK Y ALTER SAVEPOINT

Repeatable
Read uncommitted Read Committed Read Serializable Y

@@TRANCOUNT Y @@TRANS @@TRASACTIONCOUNT @@TRANSACTIONS

XTEMPLET
XPATH XML Y S XSD

2 4 3 Y 7

Transactional Replications Snapshot Replications Traditional Replications


Y Merge Replications

sys.XML_indexes Y sys.XML_index sys.XML_indexes_ALL sys.XML_indexes_catalog

processadmin setupadmin Y securityadmin serveradmin


GRANT
manager
ROLE TO
BLACK,
CREATE ROLE manager CREATE ROLE manager CLARK;
GRANT create table, create GRANT create table, create GRANT
view voew create table,
TO manager; TO manager; create voew
GRANT manager TO GRANT manager ROLE TO TO BLACK
BLACK, CLARK; Y BLACK, CLARK; CLARK; None of the listed options

CREATE GENERATE
SEQUENCE SEQUENCE
SE START SE INITIATE
GENERATE SEQUENCE CREATE SEQUENCE SE WITH 30 WITH 30
SE START WITH 30 ADD START WITH 30 ADD BY INCREMEN INCREMEN
BY 20 20 T BY 20 Y T BY 20

It is better to
define two
More than primary key
one column constraints
is not with
EmpNum column or allowed for a EmpNum
ProjNum column can not EmpNum and ProjNum primary key and ProjNum
have duplicate values columns can not be nullable Y constraint separately

The Dept_id
in
EMPLOYEE Update fails
table if there are
belonging to any records
The Dept_id column in that in
All records in EMPLOYEE EMPLOYEE table belonging department EMPLOYEE
table belonging to that to that department is is set to table for that
department are deleted Y updated to spaces NULL Dept_id

The DEPARTMENT record An error is


is deleted but there is no returned as It leads to
update done on EMPLOYEE No update occurs and no data integrity unpredictabl
table Y error is given is violated e results

The
DEPARTME
NT record is
deleted and
the Dept_id
The DEPARTMENT record The DEPARTMENT record column in An error is
is deleted but there is no is deleted and the Dept_id EMPLOYEE returned as
update done on EMPLOYEE column in EMPLOYEE tabel tabel is set to data integrity
table is set to null values Y spaces is violated
1 2 3 Y 4

1 2 3 4 Y
1 2 3 Y 4

Both Both
SELECT and SELECT and
stored stored
The SELECT statement The SELECT statement procedure procedure
does not execute but stored executes but stored sp_process sp_process
procedure sp_process procedure sp_process does fail to execute
executes not execute execute successfully Y

With 1) The With 1) The


PROC runs PROC gives
successfully error as the
using the parameters
parameter are not
values supplied
supplied properly
With 2) The With 2) The
With 1) The PROC runs With 1) The PROC give error PROC gives PROC gives
successfully using the as the parameters are not error as the error as the
parameter values supplied supplied properly parameters parameters
With 2) The PROC runs With 2) The PROC runs are not are not
successfully using the successfully using the supplied supplied
parameter values supplied parameter values supplied Y properly properly
ALTER
DATABASE ALTER
<database> DATABASE
SET <database>
ALTER DATABASE TRUSTWOR SET
<database> SET THY ON TRUSTWOR
TRUSTWORTHY ON ALTER DATABASE go THY ON
go <database> SET sp_configure
sp_configure 'clr enabled', 1 TRUSTWORTHY ON 'clr' sp_configure
go go go 'clr'
reconfigure sp_configure 'clr enabled', 1 reconfigure
go Y go go reconfigures

Drop the
Use stored
extended procedures
Use Dynamic SQL in stored Use Nested stored stored that are not
procedures Y procedures procedures in use

2 times Y 16 times 32 times 31 times


IF ERROR = IF ERROR
IF @@ERROR <> 0 Y IF @@ERROR = 0 0 <> 0

Creates a
Creates a new proc new proc
get_au_name and deletes get_au_nam None of the
the proc create_other_proc Gives execution error e Y listed options

Both Both
SELECT and SELECT and
stored stored
The SELECT statement The SELECT statement procedure procedure
does not execute but stored executes but stored sp_process sp_process
procedure sp_process procedure sp_process does fail to execute
executes not execute Y execute successfully
Both Both
SELECT and SELECT and
stored stored
The SELECT statement The SELECT statement procedure procedure
does not execute but stored executes but stored sp_process sp_process
procedure sp_process procedure sp_process does fail to execute
executes not execute execute successfully Y

The
sp_use_jobs
procedure is
automatically
The created
sp_create_st before
aff procedure sp_create_st
The sp_create_staff The sp_create_staff is created aff
procedure is not created due procedure is created with a without any procedure is
to severe error warning error Y kind of errors created

With 1) With 1)
parm1 = 100, parm1 = 100,
parm2 = 200, parm2 = 200,
parm3 = 300 parm3 = 300
With 1) parm1 = 0, parm2 = With 1) Gives error due to With 2) With 2)
0, parm3 = 0 incorrect parameter passing parm1 = 100, parm1 = 0,
With 2) parm1 = 100, parm2 With 2) parm1 = 100, parm2 parm2 = 5, parm2 = 5,
= 5, parm3 = 6 = 5, parm3 = 6 parm3 = 6 Y parm3 = 6

EXEC EXEC
advance_ran advance_ran
ge 2000 ge 2000
5000 WITH 5000
EXEC advance_range 2000 EXEC advance_range 2000 NO NOCOMPIL
5000 WITH RECOMPILE Y 5000 Y RECOMPILE E
avg1 will be
100, avg2 avg1 will be
will be 100.10, avg2
avg1 will be 100.09, avg2 will avg1 will be 100.09, avg2 will 100.09 and will be 100
be 100 and avg3 will be be 100.09 and avg3 will be avg3 will be and avg3 will
100.10 100.09 Y 100.10 be 100.09

There will be
execution avg1 will be
avg1 will be displayed as avg1 will be displayed as error in the displayed as
100 100.09 statements Y 100.10

Include
DO….END Define the
as wrappers structure of
Include BEGIN….END as around the the table
wrappers around the Include the clause 'MULTI- statements rowset that
statements the function STATEMENT TABLE' in the the function you are
contains. Y CREATE statement contains. returning Y
Select * from
averageprice
bytype(15) Select * from
Select * from multi-statement using multi- function
table function Select * from statement averageprice
averagepricebytype(15) averagepricebytype(15) Y table function bytype(15)

The price
column is
changed only
if no user is
using the
averageprice
bytype
function
when the
ALTER
command is None of the
The ALTER command fails Y The price column is changed issued listed options
The
FUNCTION
The FUNCTION body gets The FUNCTION body does returns error
executed and NULL is not get executed and the if input is None of the
returned as result value of NULL is returned Y NULL listed options

The
CREATE
function is
valid and will
not give any
execution
The CREATE function is error on
valid but will give execution existence of
The CREATE function is not error that striptime is not striptime None of the
valid and gives error found function. Y listed options

The
CREATE
function is
The CREATE function is valid and will
valid but will give execution not give any
error because of use of non- execution
The CREATE function is not deterministic function error on use None of the
valid and gives error getdate() of getdate() Y listed options
The
CREATE
function is
valid but
gives
The CREATE function is execution
The CREATE function is not valid but gives execution error on use None of the
valid and gives error Y error on use of rand() of getdate() listed options

Create fails
because it is
Create fails because it is an an invalid
It creates a valid in-line table invalid type of table valued type of scalar None of the
valued function Y function function listed options
Both CREATE
CREATE and ALTER
The CREATE fails but The CREATE succeeds but and ALTER go through
ALTER succeeds ALTER fails Y fails successfully
Both CREATE
CREATE and ALTER
The CREATE fails but The CREATE succeeds but and ALTER go through
ALTER succeeds ALTER fails fails successfully Y

User name User name


applicable - applicable -
Sunil Sunil
User name User name
User name applicable - dbo User name applicable - dbo applicable - applicable -
User name applicable - Sunil Y User name applicable - dbo dbo Sunil
The authors
table is
The automatically
sp_check_au created
thors before
procedure is sp_check_au
The sp_check_authors The sp_check_authors created thors
procedure is not created due procedure is created with a without any procedure is
to severe error warning error kind of errors Y created

Both Create
and
execution Create is
goes through successful
Both Create and execution Create fails but execution without but execution
fails goes through without errors errors gives error Y
The source The source
code of the code of the
stored stored
procedure procedure
The source code of the The source code of the sp_check_au sp_check_au
stored procedure stored procedure thors is thors is
sp_check_authors is sp_check_authors is displayed displayed 3
displayed 2 times displayed once once times Y

0 -101 Y NULL -1
0 Y -101 NULL -1

The year to date sales as The year to date sales as


picked up from the titles picked up from the titles The PROC
table will be correctly table will not be correctly will give error
displayed for the book 'My displayed for the book 'My while None of the
experiments with truth' experiments with truth' Y executing listed options
once twice none Y thrice
1) The
contents of
1) The temp table
contents of are correctly
temp table displayed
are correctly 2) Error
displayed message
2) Error displayed
1) The contents of temp message 3) The
table are correctly displayed 1) Error message displayed displayed contents of
2) The contents of temp 2) The contents of temp 3) Error temp table
table are correctly displayed table are correctly displayed message are correctly
3) Error message displayed 3) Error message displayed displayed Y displayed

1) The
contents of
temp table
are correctly
1) The displayed
contents of 2) The
temp table contents of
are correctly temp table
displayed are correctly
2) Error displayed
1) The contents of temp message 3) The
table are correctly displayed 1) Error message displayed displayed contents of
2) The contents of temp 2) The contents of temp 3) Error temp table
table are correctly displayed table are correctly displayed message are correctly
3) Error message displayed 3) Error message displayed displayed displayed Y
Only three
It uses values can
dynamic sql be passed
Variable list of values can be query within into the
The nested stored procedure passed into the stored a stored stored
concept is used procedure Y procedure Y procedure

CREATE PROC
get_titles_data_by_price(@fl
ag tinyint, @value money)
AS
exec get_titles_data
@value
GO
CREATE PROC
get_titles_data_by_advance( CREATE
@flag tinyint, @value PROC
money) get_titles_dat
AS a(@flag
exec get_titles_data tinyint,
@value @value
GO money)
CREATE PROC AS
get_titles_data(@flag tinyint, if @flag = 1
@value money) select *
AS from titles
if @flag = 1 where price
exec CREATE PROC = @value
get_titles_data_by_price get_titles_data(@flag tinyint, else
@value @value money) select *
else AS from titles
exec Select * from titles where where
get_titles_data_by_advance price = @value or advance = advance = None of the
@value @value @value Y listed options
With 1)
parameters
passed:
parm1 = 0, With 1)
parm2 = 0, parameters
parm3 = 0 passed:
With 2) parm1 = 0,
With 1) Gives error - With 1) Gives error - Gives error - parm2 = 0,
Procedure 'myproc' expects Procedure 'myproc' expects Procedure parm3 = 0
parameter '@parm1', parameter '@parm1' which 'myproc' With 2)
'@parm2', '@parm3' which was not supplied expects parameters
was not supplied With 2) Gives error - parameter passed:
With 2) parameters passed: Procedure 'myproc' expects '@parm2' parm1 = 6,
parm1 = 6, parm2 = 0, parameter '@parm2' which which was parm2 = 0,
parm3 = 0 was not supplied Y not supplied parm3 = 0

sub_proc1,
sub_proc2,
sub_proc3 sub_proc3
will be will be
sub_proc1 will be executed sub_proc2 will be executed 3 executed 2 executed 32
only once times times times each
EXEC
SelectByIdLi
st
EXEC SelectByIdList @productIds
@productIds='<Products><i ='P001' and EXEC
d>3</id><id>6</id><id>15</i EXEC SelectByIdList productIds=' SelectByIdLi
d></Products>' Y @productIds='P001' P002' st

Repeatable
Read uncommitted Read Committed Read Serializable Y

multiple OLE
more than one table in a multiple SQL Server DB None of the
database databases on a server datasources Y listed options

linked_server
linked_server_name.databas linked_server_name.databas _name… database.tab
e.owner.table Y e.table table le

Access_serv
Access_server_name.datab Access_server_name.owner. er_name...ta None of the
ase.owner.table table ble Y listed options

Commit is Name of the


issued as server which
majority of failed to
servers prepare, is
It sends a Rollback It sends a rollback command reported logged for
command to all three to the server that reported a successful repair work
resource managers Y failure to prepare prepare by DBA

The
databases
Ora_db is delinked from the The changes of Ora_db are become None of the
SQL server notified to the SQL server Y semi-linked listed options

It must be a
It must be a database OLE DB It must be a
It must be a SQL Server supplied by Microsoft (eg., compliant Relational
2005 Access, Excel) data source Y Database
It allows you
to specify a It activates
It allows you to define a It allows you to display the login id that the link
linked server on the local list of linked servers defined links the between the
server on the local server Y servers servers

Transactions
requiring
user
Transactions that might Transactions updating Distributed confirmation
require a rollback multiple tables transactions Y of update

It is lock
acquired by
a process on
a resource
It is a lock acquired by a It is a lock acquired by a for the
process on the resources process on a resource prior duration of None of the
that it intends to modify to modifying it read Y listed options

TRUE FALSE Y

Only when
the
After the transaction is
second row committed or
After all the rows are read After the first row is read Y is read rolled back

TRUE Y FALSE

User1's
transaction is
blocked and
User2 will not be blocked user2 will There will be
User2 will be blocked and both will proceed Y proceed a deadlock
User1's
transaction is
blocked and
User2 will not be blocked user2 will There will be
User2 will be blocked and both will proceed Y proceed a deadlock

User1's
transaction is
blocked and
User2 will not be blocked user2 will There will be
User2 will be blocked Y and both will proceed proceed a deadlock
User1's
transaction is
blocked and
User2 will not be blocked user2 will There will be
User2 will be blocked and both will proceed Y proceed a deadlock

User1's
transaction is
blocked and
User2 will not be blocked user2 will There will be
User2 will be blocked and both will proceed Y proceed a deadlock
User1's
transaction is
blocked and
User2 will not be blocked user2 will There will be
User2 will be blocked Y and both will proceed proceed a deadlock

User1's
transaction is
blocked and
User2 will not be blocked user2 will There will be
User2 will be blocked and both will proceed Y proceed a deadlock
User1's
transaction is
blocked and
User2 will not be blocked user2 will There will be
User2 will be blocked Y and both will proceed proceed a deadlock

User1's
transaction is
blocked and
User2 will not be blocked user2 will There will be
User2 will be blocked Y and both will proceed proceed a deadlock
User1's
transaction is
blocked and
User2 will not be blocked user2 will There will be
User2 will be blocked and both will proceed Y proceed a deadlock

User1's
transaction is
blocked and
User2 will not be blocked user2 will There will be
User2 will be blocked and both will proceed Y proceed a deadlock
None of the
DELETE from TABLE1 and changes to
INSERT into TABLE2 are INSERT into TABLE2 alone database are None of the
commited is committed coMmitted Y listed options

Statement 1 The results


is self join, will be same
Statement 2 but the
Statement 1 will not execute, Statement 1 will execute, is not a self display will
Statement 2 will execute. Statement 2 will not execute. join. be different. Y

ReadUncommitted Committed SnapShot Y Consistency

Prints 'I am
here in one'
Prints 'I am
here in two'
Prints 'I am here in one' Prints 'I am Prints 'I am
Prints 'I am here in two' Y Prints 'I am here in one' here in two' here in one'
Once 2 times zero times 3 times

Both
procedures
sp_process_t
otal_one and
sp- Procedure
Procedure Procedure process_total sp_process_t
sp_process_total_two sp_process_total_one _two get wo will not
executes before executes before executed at get executed
sp_process_total_one sp_process_total_two same time Y at all

No author
profiles are Gives
Three author profiles are One author profile is retrieved execution
retrieved from authors retrieved from authors from authors error Y
Five Four Y Three Six

0 1 -1 Y -2
Two Three Y One None

The first
employee
with
lastname
All employees whose The last employee with starting with
lastname starts with 'B' are lastname starting with 'B' 'B' alone is Gives error
deleted alone is deleted deleted message Y

1) Updates
1) Updates the statistics for 1) Updates the statistics for the statistics
every table in the database every table in the database for every
every night at 1 A.M only once at 1 A.M table in the
2) Write a log entry to both 2) Write a log entry to both database
SQL Server log and SQL Server log and only once at Gives error
Windows NT application log Y Windows NT application log 1 A.M message
Prints message 'NO ROWS Prints message 'ATLEAST Prints no Gives error
FOUND' Y ONE ROW FOUND' message Y message

Two Three One None


SELECT
deptid,

name,

groupname,

CASE
groupname

WHEN
groupname
'Marketing'
THEN 'Room
1'

WHEN
groupname
'Human
Resources'
THEN 'Room
2'
SELECT deptid,
SELECT deptid, name, WHEN
name, groupname, groupname
groupname, CASE 'Production'
CASE groupname WHEN groupname THEN 'Room
WHEN 'Marketing' 'Marketing' THEN 'Room 1' 3'
THEN 'Room 1' WHEN groupname
WHEN 'Human 'Human Resources' THEN ELSE 'Room
Resources' THEN 'Room 2' 'Room 2' 4'
WHEN WHEN groupname
'Production' THEN 'Room 3' 'Production' THEN 'Room 3' END
ELSE 'Room 4' ELSE 'Room 4' FROM
END END hr.departmen None of the
FROM hr.department Y FROM hr.department t listed options
Fetch Fetch and
Fetch fails but open succeeds but open both
Fetch and Open both fail succeeds Y open fails succeed
Fetch Fetch and
Fetch fails but open succeeds but open both
Fetch and Open both fail succeeds open fails Y succeed
Fetch Fetch and
Fetch fails but open succeeds but open both
Fetch and Open both fail Y succeeds open fails succeed
Fetch Fetch and
Fetch fails but open succeeds but open both
Fetch and Open both fail succeeds open fails succeed Y

No author
profiles are Four author
Three author profiles are One author profile is retrieved profiles are
retrieved from authors retrieved from authors from authors retrieved Y
No author
profiles are Four author
Three author profiles are One author profile is retrieved profiles are
retrieved from authors retrieved from authors from authors retrieved

Severe
Prints error message and database None of the
error code Executes with no message Y error listed options
Severe
Prints error message and database None of the
error code Y Executes with no message error listed options
SELECT
deptid,
SELECT
name, deptid,

groupname, name,

CASE groupname,

WHEN CASE
groupname
IN WHEN
'Marketing' groupname =
THEN 'Room 'Marketing'
1' THEN 'Room
1'
WHEN
groupname WHEN
IN 'Human groupname =
Resources' 'Human
THEN 'Room Resources'
SELECT deptid, SELECT deptid, 2' THEN 'Room
name, name, 2'
groupname, groupname, WHEN
CASE groupname CASE groupname groupname WHEN
WHEN groupname WHEN groupname IN groupname =
= 'Marketing' THEN 'Room IN 'Marketing' THEN 'Room 'Production' 'Production'
1' 1' THEN 'Room THEN 'Room
WHEN groupname WHEN groupname 3' 3'
= 'Human Resources' THEN IN 'Human Resources'
'Room 2' THEN 'Room 2' ELSE 'Room ELSE 'Room
WHEN WHEN 4' 4'
groupname = 'Production' groupname IN 'Production'
THEN 'Room 3' THEN 'Room 3' END END
ELSE 'Room 4' ELSE 'Room 4' FROM FROM
END END hr.departmen hr.departmen
FROM hr.department FROM hr.department t t Y
Gives
execution
One book title Two book titles Y None error

No rows are
One row is fetched from Two rows are fetched from fetched from Gives error
titles Y titles titles message Y
One row
each is Gives
fetched from execution
No rows are fetched from One row fetched from titles titles and error
either titles or authors and no rows from authors authors Y message
One book title is fetched One author Gives
from titles and one author profile is execution
profile is fetched from One book title is fetched fetched from error
authors Y from titles authors message
One book title is fetched One book title is fetched One book Gives
from titles and one author from titles and two author title is execution
profile is fetched from profiles are fetched from fetched from error
authors authors Y titles message
Gives error
Five authors Three authors Y No authors message
Prints message 'NO ROWS Prints message 'ATLEAST Prints no Gives error
FOUND' ONE ROW FOUND' message Y message

None of the
Element Centric Attribute Centric Y Xml Centric listed options
SELECT *
FROM SELECT *
EMPLOYEE FROM
ORDER BY EMPLOYEE
SELECT * FROM SELECT * FROM EMPNAME ORDER BY
EMPLOYEE EMPLOYEE FOR XML EMPNAME
ORDER BY EMPNAME ORDER BY EMPNAME RAW FOR XML
FOR XML RAW FOR XML RAW ,XSINIL ,ELEMENTS Y ELEMENTS

SELECT * SELECT *
FROM FROM
EMPLOYEE EMPLOYEE
ORDER BY ORDER BY
SELECT * FROM EMPNAME EMPNAME
SELECT * FROM EMPLOYEE FOR XML FOR XML
EMPLOYEE ORDER BY EMPNAME RAW,ELEM RAW,ELEM
ORDER BY EMPNAME FOR XML ENTS ENTS
FOR XML ELEMENTS RAW('ROW!'),ELEMENTS ROOT('ROW ROOT('ROO
ROOT('ROOT') ROOT('ROOT') ') T') Y

XMLSCHEM
XSINIL Y XMLDATA A XMLAUTO

BINARY BINARY
BINARY BASE16 BINARYBASE32 BASE64 Y BASE128
Both the Both the
Statement 1 is True, and Statement 1 is False, and Statements Statements
Statement 2 is False Statement 2 is True are True Y are False

None of the
RAW AUTO EXPLICIT Y listed options

TRUE FALSE Y

QUERY() VALUE() EXISTS() NODES() Y

Query()
method is
not
Query() method does not supported
support searching in XML Query() method is Case against the None of the
file. Sensitive Y XML Column listed options
Query() Exists() Values() Nodes()

The query
gets
executed
Compliation fails as Compliation fails as Raw and returns a
ELEMENTS is not supported method does not support XML result None of the
with Raw method joins set Y listed options

Compliation Compliation
fails as fails as
AUTO AUTO
Compliation fails as AUTO Compliation fails as AUTO method does method does
method does not support method does not support not support not support
joins ELEMENTS SELECT Row naming Y

XMLDATA
XSINIL does does not
ELEMENTS does not not support support
Raw does not support ROOT support ROOT and Row ROOT and ROOT and
and Row naming naming Row naming Row naming Y
SELECT *
FROM SELECT *
SALES FROM
ORDER BY SALES
ID ORDER BY
SELECT * FROM SALES SELECT * FROM SALES FOR XML ID
ORDER BY ID ORDER BY ID RAW('CHILD FOR XML
FOR XML FOR XML '), XSINIL, RAW('CHILD
RAW('CHILD'),Elements RAW('CHILD'),Elements, ROOT('ROO '),Elements
XSINIL, ROOT('ROOT') Y ROOT('ROOT') T') XSINIL

The query
gets
executed
and returns a
The query returns a XML result set
result set with the xml The query returns a xml which is not Error in the
namespace as the property result set in a xml schematic a XML above
of the Root node only way Y format statement

BASE32 BASE64 Y ENCODE32 ENCODE64


<contentTabl <contentsTa
e ble
contents="ta content="tabl
ble" /> e" />
<contentsTable <contents <contentTabl <contentsTa
contents="table" /> contentstable="table" /> e ble
<contentsTable <contents contents="ch content="cha
contents="chair" /> Y contentstable="chair" /> air" /> ir" />

Both the Both the


Queries will Queries will
NOT return NOT return
the same the same
result result
because because
'PATH' 'PATH'
Both the Queries will return Both the Queries will return clause is clause is
the same result because the same result because Element attribute
'PATH' clause is Element 'PATH' clause is attribute centric by centric by
centric by default Y centric by default default defalut

Returns a
xml result set
with ROW
tag name as
PRODUCT
and ROOT
Returns a xml result set with Returns a xml result set with tag name as Error in the
ROW tag name as ROOT tag name as PRODUCTIT above
PRODUCTITEM PRODUCTITEM EM statement Y

SELECT
ID,CONTEN
TS 'text()'
FROM ITEM
SELECT ID, CONTENTS SELECT ID,CONTENTS FOR XML
'string()' FROM ITEM 'innerstring()' FROM ITEM PATH('PRO
FOR XML FOR XML DUCTITEMS Error in the
PATH('PRODUCTITEMS'),R PATH('PRODUCTITEMS'),R '),ROOT('PR above
OOT('PRODUCT') OOT('PRODUCT') ODUCT') Y statement
<PRODUCT
> <PRODUCT
>
<PRODUCTI
TEMS> <PRODUCTI
TEMS>
<work> <?CONT
<worker table?>
id="1 2 0" /> <worker
</work> id="1 2 0" />

</PRODUCT </PRODUCT
<PRODUCT> ITEMS> ITEMS>
<PRODUCTITEMS>
<?CONT table?> <PRODUCT> <PRODUCTI <PRODUCTI
<work> <PRODUCTITEMS> TEMS> TEMS>
<worker id="1 2 0" /> <?CONT table?> <work> <?CONT
</work> <work> <worker chair?>
</PRODUCTITEMS> <worker id="1 2 0" /> id="1 2 0" /> <worker
<PRODUCTITEMS> </work> </work> id="1 2 0" />
<?CONT chair?> <?CONT chair?>
<work> <work> </PRODUCT </PRODUCT
<worker id="1 2 0" /> <worker id="1 2 0" /> ITEMS> ITEMS>
</work> </work>
</PRODUCTITEMS> </PRODUCTITEMS> </PRODUCT </PRODUCT
</PRODUCT> Y </PRODUCT> > >

SELECT ID,
contents
'comment()' SELECT ID,
+' contents as
Comments :' 'comment()'
SELECT ID, 'Comments: ' + FROM ITEM FROM ITEM
SELECT ID, 'Comments: ' + contents 'comment()' FROM FOR XML FOR XML
contents 'text()' FROM ITEM ITEM PATH('PRO PATH('PRO
FOR XML FOR XML DUCTITEMS DUCTITEMS
PATH('PRODUCTITEMS'),R PATH('PRODUCTITEMS'),R '),ROOT('PR '),ROOT('PR
OOT('PRODUCT') OOT('PRODUCT') Y ODUCT') ODUCT')

processing-
text() comment() instruction() Data() Y
SELECT ID,
contents
'tagname/con
tents' FROM
SELECT ID, contents SELECT ID, contents as ITEM
'tagname/@contents' FROM 'tagname/@contents' FROM FOR XML
ITEM ITEM PATH('PRO
FOR XML FOR XML DUCTITEMS
PATH('PRODUCTITEMS'),R PATH('PRODUCTITEMS'),R '),ROOT('PR None of the
OOT('PRODUCT') Y OOT('PRODUCT') ODUCT') listed options

LET Y FOR WHERE ORDER BY

UPDATE UPDATE
BOOKS SET BOOKS SET
AUTHORXM AUTHORXM
L.MODIFY(' L.MODIFY('
INSERT INSERT
UPDATE BOOKS SET <books>Sql <books>Sql
AUTHORXML.MODIFY(' UPDATE BOOKS SET server by server by
INSERT <books>Sql server AUTHORXML.MODIFY(' Mr.SHAM</b Mr.SHAM</b
by Mr.SHAM</books> INSERT <books>Sql server ooks> NEXT ooks> INTO
AFTER by Mr.SHAM</books> (subject/data (subject/data
(subject/database/@books) BEFORE (subject/database/ base/@book base/@book
[1]') @books)[1]') s)[1]') Y s)[1]')
Both the Both the
Statement 1 is True, and Statement 1 is False, and Statements Statements
Statement 2 is False Statement 2 is True Y are True are False

Both the Both the


Statement 1 is True, and Statement 1 is False, and Statements Statements
Statement 2 is False Y Statement 2 is True are True are False

Both the Both the


Step1 is valid, and Step2 is Step1 is valid, and Step2 is Steps are Steps are
invalid invalid Y valid invalid

TRUE Y FALSE

It isolates the
It takes an database
It maintains a snapshot of exclusive from access
the data for the duration of It maintains statement level lock on the to other
the transaction Y snapshot of the data entire table users

1 Y 2 Unlimited 1024
TRUE Y FALSE

Updates
made to
statistics
used by the
Modifications to table or view execution All of the
referenced by query Lot of changes to key data plan listed options Y

SELECT
column1
from table1
SELECT column1 from SELECT column1 from WHERE SELECT
table1 WHERE column1 = table1 WHERE column1 <> column1 = column1
123; Y 123; @value1 from table1
User 2 will
get an
update error Both the
User2's update will be User 1 will get an update due to updates will
overwritten by user1's error due to Snapshot snapshot be
update isolation Y isolation successful

a,b,c a,c,b b,c,a Y b,a,c


2 5 7 10 Y

5 7 10 12 Y
Update to
123 is rolled
back but
Update to 456 is rolled back Both the update to
The entire transaction is but update to 123 is updates are 456 is
rolled back Y committed comitted committed

Book id 3 is
inserted but Neither of
Book id's 2 and 3 are Book id 2 is inserted but 3 is 2 is not the books
inserted successfully not inserted Y inserted are inserted
Book id 3 is
inserted but Neither of
Book id's 2 and 3 are Book id 2 is inserted but 3 is 2 is not the books
inserted successfully not inserted inserted are inserted Y

The
procedure
creation is
successful
and while The
The procedure creation is The procedure creation is executing, it procedure
successful and while successful and while will not return creation fails
executing, it will return a xml executing, it will return a xml a xml file due due to
file with INDIA as root node file with STATE as root node to run-time compilation
and STATE as row node and INDIA as row node error error Y
Query will return a result set Query will return a result set Select
with SNO as STATE_CODE with SNO as node and statement is None of the
and SNAME as node SNAME as STATE_CODE not valid Y listed options
The
database file
names need
not be
unique

Local
procedures
are private
and under
control of the
user who
created it
The
procedure is
defined in a
sys schema Y
Because
there is no
data access
in the
process, a
cursor is
unnecessary.
Any process
with a set of
complex
mathematical
operations to
perform will
probably
operate more
efficiently by
using a CLR
procedure
Multi-
statement
UDFs allow
you to
perform the
required
operations

Dyamic Sql
stmts and
cursor logics
cannot be
rewritten
easily as
functions

Only
drop/create
or ALTER
will achieve
the
modifications
. Cannot
create
another
procedure
with same
name and
cannot alter
once
dropped

Since the
owner is
same as
creator, user
of SP inherits
rights on the
table within
the context
of SP
we can
include in
line
11 FETCH
NEXT FROM
contact_curs
or
13 CLOSE
contact_curs
or
14
DEALLOCAT
ALLOCATE E
contact_curs contact_curs
or or
first, last and
none are the
valid
SECOND values…
We can go
for UDT
which can be
like a global
variable that
can be used
in all the
places of the
application.

Every time
sqlserver is
restarted it
creates a
new
workspace in
tempdb
database.

view the
columns
associated
with the
constraint
names in the
USER_CON
S_COLUMN
S view.
If a database
is over-
normalized,
i.e. the
database is
defined with
numerous,s
mall.interrela
ted tables,db
performance
is reduced.
This is
because
when the db
processes
the data in
numerous,s
mall,interrela
ted tables,it
has to
combine the
related
data,which
results in an
increase in
the
database's
workload. In
these
situations,
denormalizin
g the
database
slightly can
improve
performance
Sub-query in
this answer
will return
one row
value,
concatenate
d first and
last name for
the
employee
with ID 180,
so update
will be
successful.
When sub-
queries are
linked to the
parent by
equality
comparisons,
the parent
query
expects only
one row of
data
The purpose
of the
UPDATE
command is
exactly what
you want to
avoid. You
should be
able to
increase the
data storage
size and alter
a column
name without
affecting the
internal data.
However, a
decrease in
the data
storage size
results in
data
truncation or
loss.
INSERT,
used
appropriately
, adds data
but does not
alter any
existing
Decreasing column length values
It adds files
to file
groups.
text column
cannot be
None of the listed options
Y changed

new column
can be
added only in
the end
With check
option we
cannot
update the
column that
would
change the
view retrieval
contents

view does
not support
order by, so
the select
stmt cannot
be exactly
created as a
view

only one
clustered
index is
allowed, the
second one
will fail
default is
ASC for first
one

unique
clustered
cannot be
created
because
already one
clustered
indx exists

keeps
address data
in index for
immediate
retrieval

drop finally
removes the
index
cannot
rebuild a
dropped
index, gives
error

It is DDL
trigger

Online
indexing
operation
ispossible
with ONLINE
= ON
UPDATE
function
restricts
changes to
city and
trigger rolls
back update

UPDATE
function
disallows
insert also
since insert
is given as
option and
trigger
rollsback
insert
Even if city is
not part of
insert, the
trigger fires
and rollsback
insert since
INSERT
option is
given

The row is
added since
INSERT is
not part of
trigger option
Since
INSTEAD of
trigger is
used, it gets
fired before
update takes
place and
update is
ignored

Since
INSTEAD of
trigger is
used, update
in the trigger
will be
applicable
database
trigger
activates and
rollbacks for
any DDL
stmt on
tables

DDL trigger
for event
notification

Use Instead
of trigger on
the view to
overcome
problem of
updating
multiple base
tables of a
view
siince after
trigger is
used, the
delete stmt
fails before
after trigger
code is
executed

first and last


are fixed,
tr_1, tr_2, other two in
tr_4, tr_3 Y any order
since nested
trigger option
is set off, the
nested
trigger does
not fire

fixed server
roles can
manage
linked
servers by
using
setupadmin
In the
administratio
n part we
can create a
role by using
the create
statement
with the
grant
command to
the various
users.

It will
generate
from 30 and
increments
from 20
The result
set will be as
follows:
1001 400
1
1004 300
2
1007 250
3
1003 200
4

The result
set will be as
follows:
1001 400
1
1004 300
2
1007 300
2
1003 200
4
The result
set will be as
follows:
1001 400
1
1004 300
2
1007 300
2
1003 200
3

without exec
the first stmt
is identified
as a sp

once
parameter by
name is
supplied, all
other
following
parameters
should be by
name only,
so 1) fails,
whereas
once position
is given then
subsequent
parameter
can be
switched to
by name
dynamic sql
in sp will
allow
creation of
queries
dynamically

None of the 2 times it will


listed options be called
sp_process
is treated as
an alias for
table
employees
EXEC is
valid and
executes

only warning
error if
another
stored
procedure
object is
mising

With 1)
parm1 = 100,
parm2 = 200, default
parm3 = 300 parameters
With 2) in first case
Gives error and second
due to invalid case only
parameter parm1 is
passing default

since proc
has
recompile
option,
explicit
recompile is
not needed
when
invoking
All the three
avg1 will be are
100, avg2 equivalent
will be 100 and perform
and avg3 will same
be 100 function

since the
schema
name is
missing,
there will be
execution
error

begin end is
a must for
multi stmt
table
function, also
table
structure
definition
simple
reference to
function is
enough to
use it

cannot alter
when the
column is
used in a
function
the
declaration
wil by pass
invoking the
function body

one function
can call
another -
nesting

getdate()
valid built in
non-
deterministic
function to
be used
rand() is not
a valid builtin
non-
deterministic
function that
can be used

inline table
function valid
type
cannot
modify
function from
inline to multi
table
can modify
inline
function
stmts

execte as
overrides the
user name to
sunil
delayed
resolution is
permitted, no
error during
create for
table objects

since
delayed
resolution is
possible
create goes
through, but
execution
gives error
on missing
table authors
All three
stmts can be
used to
display
None of the source code,
listed options so 3 times

The
statement
will fail as the
ITEM_ID
value is
larger than
allowed. The
CATCH
None of the block will
listed options return -101
Since the
statement is
successful,
the
statement
following the
CATCH
None of the block will be
listed options executed

Since
OUTPUT
keyword is
missing,
output
variable will
not be
passed back
to the
variable
Since
message is
not displayed
for incorrect
title, count is
0
##temp is
global,
#temp is
local so gets
destroyed
after
exection of
the sp, while
global exists
and hence
gives error
when proc is
again
executed

##temp is
global,
#temp is
local so gets
destroyed
after
exection of
the sp, while
global exists,
dropped and
hence goes
through both
times
uses
dynamic sql
with variable
list passed
as parameter

multiple
stored
procedures
can be
created
since default
parameter is
not
mentioned,
gives error
for first
parameter,
and in
second case
since second
parameter is
missing
None of the gives error
listed options on parm2

being a
recursive
procedure,
will abort
once
nestinglevel
None of the of 32 is
listed options Y reached
EXEC
SelectByIdLi
st
@productIds
='<Products>
<id>3</id><i
d>6</id><id>
15</id></Pro
ducts>'
No block
because
Update lock
is compatible
with Shared
lock

Only one
transaction
can have the
update lock
on row 2.
No block as
the locks are
on separate
records

Read
Committed
isolation
level drops
the shared
lock in
Transaction
A after the
read.
User2 cannot
get the
shared lock
on the key
until User1
gives up its
exclusive
lock.

User2 cannot
get the
shared lock
on the key
until User1
gives up its
exclusive
lock.
The results
of these
queries will
be same, just
will look
different. In
first
statement
driving
column is ID,
in second
-MANAGER_
ID.

BREAK will
break the
Prints loop since 1
nothing =1
None of the End less
listed options Y loop

wait for delay


delays by 2
hrs 22
seconds ,
Procedure time fires at
sp_process_ 22 seconds
one will not after 2 a.m,
get executed so both fire
at all at same time

cannot use
relative, with
forward_only
cursor
Next and first
None of the retrive same
listed options rows

no more
rows, so -1 is
returned
None of the which gets
listed options printed
both cursor
and cursor
variable used
Gives error interchangea
message bly

Cannot
update/delet
e with
fast_forward
option

while loop
keeps it
running, and
waitfor time
will make
sure at 1 am
the update is
done
since cursor
check does
not do
anything,
message
dispalyed for
fetch status
check

Since cursor
variable is
not set to
Gives error cursor , error
message Y occurs
open
succeeds
since not
fully
dealocated
since fully
deallocated
at the end,
cannot open
after that
since both
references
are
deallocated,
cannot fetch
or open
since not
deallocated,
open works

Gives error fast forward


message allows next
with fast
forward next
Gives error only is
message Y allowed

since not
exists is
satisfied,just
returns no
message
since temp
proc is
invoked, it
gives divide
by 0 error
and error
message is
printed
regular case
is converted
None of the to boolean
listed options case as in 4
since global
cursor is
declared,
fetch in
sp_two
works

since local
cursor used,
only one row,
and sp_two
gives error
that c1 is
invalid
local cursors
can be with
same name,
hence valid
and one row
fetched from
authors and
titles each
since cursor
is open, fetch
of c2 from
sp_one
should work
since cursor
is not
deallocated,
it is available
even after
sp_one
finishes
execution
and hence
c2 is
available for
fetch
Since cursor
rows is
checked and
returned, no
message is
printed
BINARY
BASE64 is
the only
available
encoding
technique
Pro-long part
is an optional
one when
used along
with 'WITH'
Statement.
None of the
listed options Y
XSINIL will
not support if
no
ELEMENTS
is used
only ALTER
TABLE and
CREATE
INDEX are
optimized.

Query
optimizer
treats the
same table
as two
different
table for self
join

None of the
listed options

None of the
listed options
If the same
query or
stored
procedure is
executed
again and
the plan is
still available
in the
procedure
cache, the
steps to
optimize and
generate the
execution
plan are
skipped, and
the stored
query
execution
plan is
reused to
execute the
query or
stored
procedure.
Compilation
fails because
passing a
variable is
not possible
in ROOT
clause
Value
function is
not
supported in
dynamic
table

Você também pode gostar