SQL PDF Raviraj
SQL PDF Raviraj
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
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
Stored
procedures
and Which of the following is not an
18 Single ChoiceComprehension
Average Functions advantage of Stored Procedure? 1
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
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
,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
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:
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:
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
IF UPDATE(city)
BEGIN
ROLLBACK TRAN
END
GO
UPDATE authors
SET city = 'MUMBAI'
WHERE au_id = '1001'
IF UPDATE(city)
BEGIN
ROLLBACK TRAN
END
GO
IF UPDATE(city)
BEGIN
ROLLBACK TRAN
END
GO
IF UPDATE(city)
BEGIN
ROLLBACK TRAN
END
GO
sp_process
Stored SELECT * from employees
procedures
Single and What is the outcome of above
112 Choice Application Average Functions execution? 1
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
SELECT @avg1 =
dbo.averagebookprice('computers')
SET @avg2 =
dbo.averagebookprice('computers')
EXEC @avg2 =
dbo.averagebookprice 'computers'
SET @avg1 =
averagebookprice('computers')
GO
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
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
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
CREATE FUNCTION
dbo.getonlydate()
RETURNS datetime
as
BEGIN
DECLARE @date datetime
SET @date = dbo.striptime(getdate())
RETURN @date
END
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
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
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
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
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
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 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
Transactions
and XML Distributed queries allow you to collect
Single Support in and manipulate data from
152 Choice Knowledge Easy SQL Server __________________________ 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
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
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
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
id int(9)
name varchar(2)
manager_id int(9)
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
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
DECLARE authors_cursor
FORWARD_ONLY FOR
SELECT au_lname, au_fname FROM
authors
ORDER BY au_lname, au_fname
OPEN authors_cursor
CLOSE authors_cursor
DEALLOCATE authors_cursor
OPEN authors_cursor
CLOSE authors_cursor
DEALLOCATE authors_cursor
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
OPEN abc
CLOSE @cba
DEALLOCATE abc
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
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:
OPEN authors_cursor
IF @@CURSOR_ROWS = 0
END
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
CLOSE @cba
DEALLOCATE abc
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:
DECLARE authors_cursor
FAST_FORWARD FOR
SELECT au_lname, au_fname FROM
authors
ORDER BY au_lname, au_fname
OPEN authors_cursor
DECLARE authors_cursor
FAST_FORWARD FOR
SELECT au_lname, au_fname FROM
authors
ORDER BY au_lname, au_fname
OPEN authors_cursor
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:
OPEN authors_cursor
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
au_lname au_fname
BHARAT IYER
ASHISH MALHOTRA
BIDYUT THAKUR
ANISH MATRE
BALA SUBRAMANIAN
OPEN authors_cursor
IF @@CURSOR_ROWS = 0
BEGIN
CLOSE authors_cursor
DEALLOCATE authors_cursor
RETURN
END
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
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
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
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
ITEM ID CONTENTS
1 Table
2 Chair
ID CONTENTS
1 Table
2 Chair
<PRODUCT>
<PRODUCTITEMS>
<?CONT table?>
<work>
<worker id="1 2 3 4" />
</work>
</PRODUCTITEMS>
OUTPUT:
<PRODUCT>
<PRODUCTITEMS>
<ID>1</ID>
<tagname contents="table" />
</PRODUCTITEMS>
<PRODUCTITEMS>
<ID>2</ID>
<tagname contents="chair" />
</PRODUCTITEMS>
</PRODUCT>
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:
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
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 -
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
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
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
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
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
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
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
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
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.
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
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
Repeatable
Read uncommitted Read Committed Read Serializable Y
XTEMPLET
XPATH XML Y S XSD
2 4 3 Y 7
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
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
Drop the
Use stored
extended procedures
Use Dynamic SQL in stored Use Nested stored stored that are not
procedures Y procedures procedures in use
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
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
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
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
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
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()
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
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
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
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
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
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
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
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
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