sql pdf raviraj

249
1 True or False Knowledge Easy 1 2 Easy 1 3 Average 2 4 Average 3 5 Average 1 6 Average 2 Database files and Data files Views and Partition Tables It is mandatory to define at least one secondary data file for a database. State True or False. Single Choice Comprehensi on Database files and Data files Views and Partition Tables 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, DELETE) for partitioned(multiple partition) tables are different from that of a single partition table. Which of the following is applicable for above? Multiple Choice Comprehensi on Database files and Data files Views and Partition Tables Which of the following are correct with respect to Filegroups?(Choose 2) Multiple Choice Comprehensi on Database files and Data files Views and Partition Tables When creating a database, which of the following should be considered when selecting the location of the database files?(Choose 3) Single Choice Comprehensi on Database files and Data files Views and Partition Tables Consider the following statements with respect to Views: Statement 1: Index on a view takes up physical storage and requires maintenance. Statement 2: Local partitioned view utilises base tables that reside on the same server. Which of the following is applicable for above? Multiple Choice Comprehensi on Stored procedures and functions Which of the following are features of a local temporay stored procedure? (Choose 2)

Upload: ravirajparab

Post on 10-Apr-2015

309 views

Category:

Documents


1 download

DESCRIPTION

this is sql dumps uploaded by raviraj

TRANSCRIPT

Page 1: SQL PDF Raviraj

1 True or False Knowledge Easy 1

2 Easy 1

3 Average 2

4 Average 3

5 Average 1

6 Average 2

Database files and Data files Views and Partition Tables

It is mandatory to define at least one secondary data file for a database.State True or False.

Single Choice

Comprehension

Database files and Data files Views and Partition Tables

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, DELETE) for partitioned(multiple partition) tables are different from that of a single partition table.

Which of the following is applicable for above?

Multiple Choice

Comprehension

Database files and Data files Views and Partition Tables

Which of the following are correct with respect to Filegroups?(Choose 2)

Multiple Choice

Comprehension

Database files and Data files Views and Partition Tables

When creating a database, which of the following should be considered when selecting the location of the database files?(Choose 3)

Single Choice

Comprehension

Database files and Data files Views and Partition Tables

Consider the following statements with respect to Views:

Statement 1: Index on a view takes up physical storage and requires maintenance.Statement 2: Local partitioned view utilises base tables that reside on the same server.

Which of the following is applicable for above?

Multiple Choice

Comprehension

Stored procedures and functions

Which of the following are features of a local temporay stored procedure?(Choose 2)

Page 2: SQL PDF Raviraj

7 Average 2

8 Average 1

9 Average 3

10 Average 1

11 Average 2

Multiple Choice

Comprehension

Stored procedures and functions

Which of the following are correct for temporary tables used in Stored procedures?(Choose 2)

Single Choice

Comprehension

Stored procedures and functions

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

Which of the following is applicable for above statements?

Multiple Choice

Comprehension

Stored procedures and functions

Which of the following attributes characterise System Stored Procedures?(Choose 3)

Single Choice

Comprehension

Stored procedures and functions

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.

Which of the following is applicable for above statements?

Multiple Choice

Comprehension

Stored procedures and functions

Which of the following cannot be passed as input parameter values to a Stored procedure?(Choose 2)

Page 3: SQL PDF Raviraj

12 True or False Average 1

13 Average 1

14 Average 1

15 Average 1

Comprehension

Stored procedures and functions

Consider the following statement:

Select title_id, price, type from titles where price > dbo.AverageBookPrice('comp_science')

What kind of a User Defined Function is used in the above statement?

Single Choice

Comprehension

Stored procedures and functions

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.

Which of the following is applicable for the above?

Single Choice

Comprehension

Stored procedures and functions

You are currently working with an application with lage processor-intensive calculations.

Which of the following stored procedure would you prefer?

Single Choice

Comprehension

Stored procedures and functions

Which of the following error type can be handled within a TRY..CATCH construct of handling errors in stored procedures?

Page 4: SQL PDF Raviraj

16 Average 1

17 Average 1

18 Single ChoiceComprehensionAverage 1

19 Complex 2

20 Complex 2

21 Complex 1

22 Single ChoiceKnowledge Average Cursors 1

23 Single ChoiceComprehensionAverage Cursors 1

Single Choice

Comprehension

Stored procedures and functions

Which of the following type of statement are allowed to be included in a User Defined Function?

Single Choice

Comprehension

Stored procedures and functions

You have to perform operations like inserts, deletes, updates on the contents of a table variable before returning a result set.

Which of the following User Defined Function will be suitable to define for the above scenario?

Stored procedures and Functions

Which of the following is not an advantage of Stored Procedure?

Multiple Choice

Comprehension

Stored procedures and functions

Which of the following stored procedures are ideal candidates to be re-written as User Defined Functions?(Choose 2)

Multiple Choice

Comprehension

Stored procedures and functions

You have a stored procedure and you need to make some modifications to it.

Which of the following ways can this be done?(Choose 2)

Single Choice

Comprehension

Stored procedures and functions

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 tableStatement 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

Which of the following is applicable for the above?

Which of the following option defines a cursor that makes a temporary copy of the data to be used by the cursor?

Which of the following options is used to retrieve the second record from a table?

Page 5: SQL PDF Raviraj

24 Average Cursors 1

25 Average Cursors 1

26 Average Cursors 1

27 Average Cursors 3

Single Choice

Comprehension

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.

Which of the following is applicable for above?

Single Choice

Comprehension

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.

Which of the following is applicable for above?

Single Choice

Comprehension

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

Which of the following is applicable for above?

Multiple Choice

Comprehension

Below is a code snippet for cursor:

01 USE AdventureWorks02 GO03 DECLARE contact_cursor CURSOR FOR04 SELECT LastName FROM Person.Contact05 WHERE LastName LIKE 'B%'06 ORDER BY LastName07 OPEN contact_cursor08 FETCH NEXT FROM contact_cursor09 WHILE @@FETCH_STATUS = 010 BEGIN11 ---- Missing Line 12 END13 ---- Missing Line14 ---- Missing Line

Which of the following lines of code can be correctly fitted into the missing lines?(Choose 3)

Page 6: SQL PDF Raviraj

28 Single ChoiceComprehensionAverage Cursors 1

29 True or False Knowledge Easy 1

30 Average 1

31 Average 3

32 Average 1

33 Average 2

34 Single ChoiceKnowledge Easy 1

35 Single ChoiceKnowledge Easy SQL server 2005 overview 1

36 True or False Knowledge Easy SQL server 2005 overview 1

Which of the following cursor creation option specifies that all fetch options (FIRST,LAST,PRIOR,NEXT,RELATIVE,ABSOLUTE) are available?

Triggers and Indexes

The INSTEAD of trigger can be applied to a view and triggered based on the modifications to the view.State True or False.

Single Choice

Comprehension

Triggers and Indexes

Which of the following is limitation of INSTEAD of trigger?

Multiple Choice

Comprehension

Triggers and Indexes

In case of defining multiple triggers for an UPDATE action on a given table, which of the following are correct trigger order values?(Choose 3)

Single Choice

Comprehension

Triggers and Indexes

For which of the following it is ideal to define non-clustered indexes?

Multiple Choice

Comprehension

Triggers and Indexes

Referential integrity can be enforced by using DML triggers.

Which of the following are other methods by which the same enforcement can be achieved?(Choose 2)

Triggers and Indexes

Which of the following is a perfect match with reference to an Index?

Where are SQL Server user names and Passwords stored in sql server?

A table can not have more than one clustered index. State True or False

Page 7: SQL PDF Raviraj

37 Complex 1

38 Single ChoiceApplication Average SQL server 2005 overview 1

39 Multiple ChoiceApplication Complex SQL server 2005 overview 2

40 Single ChoiceApplication Complex SQL server 2005 overview 1

41 Single ChoiceKnowledge Easy 1

42 Single ChoiceComprehension Average 1

43 Single ChoiceComprehension Average 1

Single Choice

Comprehension

SQL server 2005 overview

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.

Which of the following feature we can use to address the above requirement?

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 database?

Which of the following are correct for indexed views?(Choose 2)

An user wants to grant all users query privileges on his/her DEPT table.

Which of the following SQL statement will help him/her accomplish this?

Implementing Data integrity,Sub queries and Joins & T-SQL enhancements and functions

When of the following subquery takes parameters from its parent query?

Implementing Data integrity,Sub queries and Joins & T-SQL enhancements and functions

Which of the following is NOT used to combine data from multiple tables?

Implementing Data integrity,Sub queries and Joins & T-SQL enhancements and functions

Which of the following helps us to create and populate a new table with the data of an existing table?

Page 8: SQL PDF Raviraj

44 Single ChoiceComprehension Average 1

45 Single ChoiceComprehensionAverage 1

46 Single ChoiceComprehensionAverage 1

47 Single ChoiceComprehensionAverage 1

Implementing Data integrity,Sub queries and Joins & T-SQL enhancements and functions

A set of statements is to be executed 10 times. Which of the following constructs can we use for this task?

Implementing Data integrity,Sub queries and Joins & T-SQL enhancements and functions

Which of the following type of integrity is correct for the statement -'Ensures that the values in a column are within the Specified Range'?

Implementing Data integrity,Sub queries and Joins & T-SQL enhancements and functions

Which of the following type of integrity maintains the relationship between tables in a database?

Implementing Data integrity,Sub queries and Joins & T-SQL enhancements and functions

Which of the following type of integrity ensures each record in a table is Unique?

Page 9: SQL PDF Raviraj

48 Single ChoiceApplication Average 1

Implementing Data integrity,Sub queries and Joins & T-SQL enhancements and functions

You work as a database developer at ABC.Inc.com. The ABC sales staff wants to track sales by multiple parameters such as age, country to be able to spot relevant sales patterns. To produce such information you need to join four tables from the highly normalized database.

Which of the following suggestion will make the query response time faster?

Page 10: SQL PDF Raviraj

49 Single ChoiceApplication Average 1

50 Single ChoiceApplication Complex 1

Implementing Data integrity,Sub queries and Joins & T-SQL enhancements and functions

Examine the structure of the EMPLOYEES and NEW_EMPLOYEES tables

employeesemployee_id INT Primary Keyfirst_name VARCHAR (25)last_name VARCHAR(25)hire_date DATE DATETIME

new_employeesemployee_id INT Primary Keyname VARCHAR(50)

Which of the following UPDATE statement is valid for the above?

Implementing Data integrity,Sub queries and Joins & T-SQL enhancements and functions

Which of the following is a valid statement about sub queries?

Page 11: SQL PDF Raviraj

51 Multiple ChoiceApplication Complex 3

52 Application Complex 1

Implementing Data integrity,Sub queries and Joins & T-SQL enhancements and functions

During the major system upgrade, multiple data changes are going to be made. You would like to implement various changes without disturbing any of the existing data.

Which of the following operations do not affect any existing data values? (Choose 3)

Single Choice

Database files and Data files Views and Partition Tables

Consider the following statements:

CREATE PARTITION FUNCTION SalesFigures (datetime)

AS RANGE RIGHT FOR VALUES

('01/01/1993', '01/01/1994', '01/01/1995')GO

What does the above partition function achieve?

Page 12: SQL PDF Raviraj

53 Application Complex 1

54 Application Complex 1

55 Application Complex 2

Single Choice

Database files and Data files Views and Partition Tables

Consider the following statements:

A view is created as follows:CREATE VIEW EmployeeViewasSELECT empid, birthdate, gender, hiredatefrom Hr.Employeeswhere hiredate > '2/1/07'

The following select statement uses the above view:

SELECT * from EmployeeViewwhere birthdate > '3/1/65'

What does the above SELECT statement retrieve?

Single Choice

Database files and Data files Views and Partition Tables

Consider the following statements:

SELECT name AS view_name ,SCHEMA_NAME(schema_id) AS schema_name ,OBJECTPROPERTYEX(object_id,'IsIndexed') AS IsIndexed ,OBJECTPROPERTYEX(object_id,'IsIndexable') AS IsIndexable ,create_date ,modify_dateFROM sys.views;

What does IsIndexable return in the above statement?

Multiple Choice

Database files and Data files Views and Partition Tables

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 AND titles.title_id = titleauthor.title_id

In case the above schema needs to qualify for creation for an index, which of the following are missing?

Page 13: SQL PDF Raviraj

56 Single ChoiceApplication Complex 1

57 Single ChoiceApplication Complex 1

58 Single ChoiceApplication Complex 1

59 Single ChoiceApplication Complex 2

60 Single ChoiceApplication Complex 1

Database files and Data files Views and Partition Tables

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 AND titles.title_id = titleauthor.title_id

In case the above schema needs to qualify for creation for an index, which of the following are missing?

Database files and Data files Views and Partition Tables

Assume that there is an indexed view defined called prod.product_details.

Which of the following gives the right example of using the view where SQL server will process the query by accessing data directly from the base tables and ignore the indexed views.

Database files and Data files Views and Partition Tables

Consider the following statements:

ALTER DATABASE EmployeeMODIFY FILE (Name = Employee_log,FILENAME = 'C:\Employee_log.ldf')

What does the above statement achieve?

Database files and Data files Views and Partition Tables

Consider the following statements:CREATE TABLE dbo.parameter (tableid int identity tabledesc shortdesc)

Which of the following give the possible interpretations of use of shortdesc as datatype?(Choose 2)

Database files and Data files Views and Partition Tables

Consider the following statements:

CREATE PARTITION SCHEME CustPS1AS PARTITION CustPS1 ALL to ([PRIMARY])GO

CREATE TABLE dbo.customers_p1(cust_id, cust_name, order_dt)ON CustPS1(order_dt)GO

What does the above statement achieve?

Page 14: SQL PDF Raviraj

61 Single ChoiceApplication Complex 1

62 Single ChoiceApplication Complex 1

63 Single ChoiceApplication Complex 1

64 Single ChoiceApplication Complex 1

65 Single ChoiceApplication Complex 1

Database files and Data files Views and Partition Tables

Consider the following statements:

CREATE TABLE dbo.Table1(Tableid int null,Tabledesc varchar(50) null)ON [userdata_FG]

CREATE CLUSTERED INDEX [ci_table1] on [dbo].[Table1]( [Tableid] ASC)

What is the outcome of the above statements?

Database files and Data files Views and Partition Tables

Assume there is a table emp defined with columns as emp_id smallintemp_name varchar(30)emp_address text

Supposing you want to modify the above table to make the emp_address column as varchar(40)which of the following ia a valid command to make the change?

Database files and Data files Views and Partition Tables

Assume there is a table emp defined with columns as emp_id smallintemp_name charemp_address char

Which of the following command can be issued to change the datatype of column emp_address from char to nchar?

Database files and Data files Views and Partition Tables

Assume there is a table emp defined with columns as emp_id smallintemp_name charemp_address char

In case you want to add a new column emp_gender after the emp_name column, which of the following can be used?

Database files and Data files Views and Partition Tables

Assume there is a table emp defined with columns as emp_id smallintemp_name charemp_address text

In case you want to add a new column emp_gender to the above table, which of the following can be used?

Page 15: SQL PDF Raviraj

66 Single ChoiceApplication Complex 1

67 Single ChoiceApplication Complex 1

68 Single ChoiceApplication Complex 1

Database files and Data files Views and Partition Tables

Consider the following statement:

CREATE VIEW sales.sales_sum_vu asSELECT datepart(yy, orderdate) as 'order_year', datepart(mm, orderdate) as 'order_month', sum(totaldue) FROM sales.sales_orderGROUP BY datepart(yy, orderdate), datepart(mm, orderdate)

What is the outcome of the above create statement?

Database files and Data files Views and Partition Tables

Consider the following statement:

CREATE VIEW sales.sales_sum_vu asSELECT datepart(yy, orderdate) as 'OrderYear', datepart(mm, orderdate) as 'OrderMonth', sum(totaldue) as 'TotalDue'FROM sales.sales_orderGROUP BY datepart(yy, orderdate), datepart(mm, orderdate)ORDER BY OrderYear, OrderMonth

What is the outcome of the above create statement?

Database files and Data files Views and Partition Tables

Consider the following statements:

CREATE VIEW sales.sales_sum_vu asSELECT datepart(yy, orderdate) as 'OrderYear', datepart(mm, orderdate) as 'OrderMonth', sum(totaldue) as 'TotalDue'FROM sales.sales_orderGROUP BY datepart(yy, orderdate), datepart(mm, orderdate)

SELECT top 5 *FROM sales.sales_sum_vuWHERE OrderYear >=2007ORDER BY OrderYear, OrderMonth

Which of the following is applicable for above statements?

Page 16: SQL PDF Raviraj

69 Single ChoiceApplication Complex 1

70 Single ChoiceApplication Complex 1

71 Single ChoiceApplication Complex 1

72 Application Complex 1

Database files and Data files Views and Partition Tables

Consider the following statements:

CREATE VIEW hr.male_emp_vuASSELECT empid, empname, empgenderFROM hr.employeesWHERE empgender = 'M' WITH CHECK OPTION

UPDATE hr.male_emp_vuSET empgender = 'F' WHERE empid = 1001

What is the outcome of the satements as above?

Database files and Data files Views and Partition Tables

Consider the following statements:

CREATE VIEW credit_card_vuASSELECT creditcardid, cardtype, cardno, expmonth, expyearFROM sales.creditcard

UPDATE credit_card_vuset expyear = expyear + 1WHERE expyear <= 2004

What is the outcome of the above statements?

Database files and Data files Views and Partition Tables

Consider the following SELECT statement:

SELECT territoryid, sum(totaldue)FROM sales.salesorderGROUP BY territoryidORDER BY territoryid

In case the same SELECT statement can be exactly achieved by using a VIEW, which of the following VIEW definition will be correct?

Single Choice

Triggers and Indexes

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)

What is the outcome of the above statements?

Page 17: SQL PDF Raviraj

73 Application Complex 1

74 Application Complex 1

75 Application Complex 1

76 Application Complex 1

Single Choice

Triggers and Indexes

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]

What is the outcome of the above statements?

Single Choice

Triggers and Indexes

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.

Which of the following will achieve the requirement?

Single Choice

Triggers and Indexes

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 INCLUDE clause in the above statement?

Single Choice

Triggers and Indexes

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 DISABLEDROP INDEX emp.idx1

What is the final outcome of issuing the above statements?

Page 18: SQL PDF Raviraj

77 Application Complex 1

78 Application Complex 1

79 Application Complex 1

Single Choice

Triggers and Indexes

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 DISABLEDROP INDEX emp.idx1ALTER INDEX idx1 ON emp REBUILD

What is the final outcome of issuing the above statements?

Single Choice

Triggers and Indexes

Below is a trigger defined :

01 USE master02 GO03 CREATE TRIGGER srv_trg_RestrictNewLogins04 ON ALL SERVER05 FOR CREATE_LOGIN06 AS07 PRINT 'No login creations without DBA involvement.'08 ROLLBACK09 GO

What does the above trigger achieve?

Single Choice

Triggers and Indexes

Assume there is an existing table 'emp' with columns as empid, empname, empdob, empaddressIn 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.

Which of the following will achieve the above?

Page 19: SQL PDF Raviraj

80 Application Complex 1

81 Application Complex 1

Single Choice

Triggers and Indexes

The following trigger is created an a table called 'authors' that has columns au_id, au_name,city

CREATE TRIGGER tr_au_upd ON authorsFOR 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'

What will be the outcome of the above statement?

Single Choice

Triggers and Indexes

The following trigger is created an a table called 'authors' that has columns au_id, au_name,city

CREATE TRIGGER tr_au_upd ON authorsFOR 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'')

What will be the outcome of the above statement?

Page 20: SQL PDF Raviraj

82 Application Complex 1

83 Application Complex 1

Single Choice

Triggers and Indexes

The following trigger is created an a table called 'authors' that has columns au_id, au_name,city

CREATE TRIGGER tr_au_upd ON authorsFOR 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')

What will be the outcome of the above statement?

Single Choice

Triggers and Indexes

The following trigger is created an a table called 'authors' that has columns au_id, au_name,city

CREATE TRIGGER tr_au_upd ON authorsFOR 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')

What will be the outcome of the above statement?

Page 21: SQL PDF Raviraj

84 Application Complex 1

85 Application Complex 1

Single Choice

Triggers and Indexes

The following trigger is created an a table called 'authors' that has columns au_id, au_name,city

CREATE TRIGGER tr_au_upd ON authorsINSTEAD OF UPDATE ASPRINT '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 = 1001GO

SELECT au_id, au_name WHERE au_id =1001GO

What will be the outcome of the above SELECT statement?

Single Choice

Triggers and Indexes

The following trigger is created an a table called 'authors' that has columns au_id, au_name,city

CREATE TRIGGER tr_au_upd ON authorsINSTEAD OF UPDATE ASIF @@ROWCOUNT = 0 RETURNUPDATE authors SET au_name = 'Raman' WHERE au_id = 1001GO

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 = 1001GO

SELECT au_id, au_name WHERE au_id =1001GO

What will be the outcome of the above SELECT statement?

Page 22: SQL PDF Raviraj

86 Application Complex 1

87 Application Complex 1

88 Application Complex 1

Single Choice

Triggers and Indexes

The following trigger is scoped at database level:

CREATE TRIGGER tr_table_auditON DATABASEFOR CREATE_TABLE, ALTER_TABLE, DROP_TABLEAS ROLLBACKGO

The following statement is isused on table 'titles' in the database

ALTER TABLE titles ADD new_col INT NULLALTER TABLE titles DROP COLUMN new_col

What is the final outcome of issuing the ALTER statements?

Single Choice

Triggers and Indexes

The following trigger is created -

CREATE TRIGGER tr_index_auditON DATABASEFOR CREATE_INDEX, ALTER_TABLE, DROP_INDEXAS 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)

What is the final outcome of issuing the CREATE statement?

Single Choice

Triggers and Indexes

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.

Which of the following will achieve the above task successfully?

Page 23: SQL PDF Raviraj

89 Application Complex 1

90 Application Complex 2

Single Choice

Triggers and Indexes

Consider the following scenario:

Table 'dept' holds information about departments like deptid, deptname, locationdeptid is the primary key

Table 'emp' holds information about employees like empid, name, deptid, dateofbirthdeptid 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 statement for a deptid in the 'dept' table?

Multiple Choice

Triggers and Indexes

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 triggers in case an update operation takes place on the table?(Choose 2)

Page 24: SQL PDF Raviraj

91 Application Complex 1

92 Single ChoiceKnowledge Easy Transactions and XML Support in SQL ServerWe identify a transaction __________. 1

93 Single ChoiceKnowledge Easy Transactions and XML Support in SQL Server 1

94 Single ChoiceKnowledge Easy Transactions and XML Support in SQL Server 1

95 Single ChoiceKnowledge Easy Transactions and XML Support in SQL Server 1

96 Single ChoiceKnowledge Easy Transactions and XML Support in SQL Server 1

97 Single ChoiceKnowledge Easy Transactions and XML Support in SQL Server 1

98 Single ChoiceKnowledge Easy Transactions and XML Support in SQL Server 1

99 Single ChoiceKnowledge Easy Transactions and XML Support in SQL Server 1

100 Single ChoiceComprehensionAverage Transactions and XML Support in SQL Server 1

101 Single ChoiceComprehensionAverage Transactions and XML Support in SQL Server 1

102 Single ChoiceApplication Average Sql Server 2005 - overview 1

Single Choice

Triggers and Indexes

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 UPDATE statement is issued on the 'jobs' table?

Which of the following applies to SQL Server transaction?

Which of the following denotes Transaction Control command in SQL?

Which of the following command is used to undo the current transaction in SQL Server?

Which of the following is the Highest isolation level in SQL Server 2005?

Which of the following we can use to identify the number of active transactions for current connection?

Which of the following is used to locate specific content and elements within an XML document?

XML columns can only have one primary XML index defined.How many maximum secondary indices can be defined?

Which of the following is NOT a valid Replication type?

Which of the following command is used to view the XML indexes used in the database?

Which of the following fixed server roles can manage linked servers?

Page 25: SQL PDF Raviraj

103 Single ChoiceApplication Complex Sql Server 2005 - overview 1

104 Single ChoiceApplication Complex Sql Server 2005 - overview 1

105 Application Average 1

106 Application Average 1

107 Application Average 1

108 Application Average 1

You need to perform these tasks:

01 Create and assign a MANAGER role to Blake and Clark02 Grant CREATE TABLE and CREATE VIEW privileges to Blake and Clark

Which of the following set of SQL statements achieves the desired results?

Which of the following SQL statement create a sequence SE with starting value as 30 and in increments of 20?

Single Choice

Implementing Data integrity,Sub queries and Joins & T-SQL enhancements and functions

There is a project allocation table which has the following structure:EmpNum int, ProjNum int, AllocDate DateTime, ReleaseDate DateTimeEmpNum and ProjNum form the composite primary key and we want to define aPrimary Key constraint with those columns.Choose a valid statement for the above scenario.

Single Choice

Implementing Data integrity,Sub queries and Joins & T-SQL enhancements and functions

The HR database in a company has EMPLOYEE and DEPARTMENT tables.Dept_id, the primary key of DEPARTMENT table, is defined as a foreign key in the EMPLOYEE table with ON DELETE CASCADE optionWhat happens when a department is deleted in the DEPARTMENT table?

Single Choice

Implementing Data integrity,Sub queries and Joins & T-SQL enhancements and functions

The HR database in a company has EMPLOYEE and DEPARTMENT tables.Dept_id, the primary key of DEPARTMENT table, is defined as a foreign key in the EMPLOYEE tableWhat happens when a department, with no associated EMPLOYEE records, is deleted in the DEPARTMENT table?

Single Choice

Implementing Data integrity,Sub queries and Joins & T-SQL enhancements and functions

The HR database in a company has EMPLOYEE and DEPARTMENT tables.Dept_id, the primary key of DEPARTMENT table, is defined as a NULL column and a foreign key in EMPLOYEE table. What happens when a department is deleted in the DEPARTMENT table?

Page 26: SQL PDF Raviraj

109 Application Complex 1

110 Application Complex 1

Single Choice

Implementing Data integrity,Sub queries and Joins & T-SQL enhancements and functions

Consider the following table (ORDERS)

OrderNum Amount ODATE CustNum3001 250 03-oct-94 10073003 200 03-oct-94 10013002 300 03-oct-94 10043005 200 04-oct-94 10013004 200 04-oct-94 1003

What will be the Row_Number for CustNum of 1007 in the following query?select CustNum, sum(Amount),ROW_NUMBER () OVER (order by sum(Amount) DESC) as Row_Numberfrom ORDERS group by CustNumorder by sum(Amount) desc

Single Choice

Implementing Data integrity,Sub queries and Joins & T-SQL enhancements and functions

Consider the following table (ORDERS)

OrderNum Amount ODATE CustNum3001 300 03-oct-94 10073003 200 03-oct-94 10013002 300 03-oct-94 10043005 200 04-oct-94 10013004 200 04-oct-94 1003

What will be the Rank for CustNum of 1003 in the following query?select CustNum, sum(Amount),RANK () OVER (order by sum(Amount) DESC) as Rankfrom ORDERS group by CustNumorder by sum(Amount) desc

Page 27: SQL PDF Raviraj

111 Application Complex 1

112 Application Average 1

113 Application Average 1

Single Choice

Implementing Data integrity,Sub queries and Joins & T-SQL enhancements and functions

Consider the following table (ORDERS)

OrderNum Amount ODATE CustNum3001 300 03-oct-94 10073003 200 03-oct-94 10013002 300 03-oct-94 10043005 200 04-oct-94 10013004 200 04-oct-94 1003

What will be the Dense_Rank for CustNum of 1003 in the following query?select CustNum, sum(Amount),DENSE_RANK () OVER (order by sum(Amount) DESC) as Dense_Rankfrom ORDERS group by CustNumorder by sum(Amount) desc

Single Choice

Stored procedures and Functions

Consider a table 'employees' and a stored procedure 'sp_process'

The following statements are executed:

sp_processSELECT * from employees

What is the outcome of above execution?

Single Choice

Stored procedures and Functions

Consider the following statements:

CREATE PROC myproc

@parm1 int, @parm2 int, @parm3 intAS----processing done hereRETURN

The above PROC is executed twice as below:1) EXEC myproc @parm1 = 4, 5, 62) EXEC myproc 4, @parm2 = 5, @parm3 = 6

What is the outcome of executing as above?

Page 28: SQL PDF Raviraj

114 Application Average 1

115 Application Average 1

116 Application Average 1

Single Choice

Stored procedures and Functions

To run stored procedures using CLR in SQL Server 2005, you will have to run a script against your database.

Which of the following gives the correct script to be run?

Single Choice

Stored procedures and Functions

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.

Which of the following will be a solution to the above recommendation?

Single Choice

Stored procedures and Functions

Consider the following stored procedures:

CREATE proc main_procASexec sub_proc1exec sub_proc2returngo

CREATE proc sub_proc1ASexec sub_proc2go

CREATE proc sub_proc2ASreturn

How many times will the proc sub_proc2 get executed upon invoking EXEC main_proc?

Page 29: SQL PDF Raviraj

117 Application Average 1

118 Application Average 1

119 Application Average 1

Single Choice

Stored procedures and Functions

Consider the following stored procedure:

CREATE PROCEDURE HumanResources.usp_DeleteCandidate ( @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; ENDELSE BEGIN -- Return 0 to the calling program to indicate success. PRINT N'The job candidate has been deleted.'; RETURN 0; END;GO

Which of the following is the correct statement that can be fitted in the ---missing line -----?

Single Choice

Stored procedures and Functions

Consider the following statement:

CREATE PROC create_other_proc as EXEC('CREATE PROC get_au_name as Select au_name from authors RETURN')

What is the outcome of the above when create_other_proc is executed?

Single Choice

Stored procedures and Functions

Consider a table 'employees' and a stored procedure 'sp_process'

The following statements are executed:

SELECT * from employeessp_process

What is the outcome of the above execution?

Page 30: SQL PDF Raviraj

120 Application Average 1

121 Application Average 1

122 Application Complex 1

123 Application Complex 2

Single Choice

Stored procedures and Functions

Consider a table 'employees' and a stored procedure 'sp_process'

The following statements are executed:

SELECT * from employeesEXEC sp_process

What is the outcome of the above execution?

Single Choice

Stored procedures and Functions

Consider the following stored procedure creation:

CREATE proc sp_create_staffASEXEC sp_use_jobs

It so happens that the user missed creating the stored procedure sp_use_jobs in the database.

What will be the outcome of the create procedure sp_create_staff as above?

Single Choice

Stored procedures and Functions

Consider the following statements:

CREATE PROC myproc @parm1 int = 100, @parm2 int = 200, @parm3 int = 300AS----processing done hereRETURN

The above PROC is executed twice as below:1) EXEC myproc 2) EXEC myproc @parm1 = DEFAULT, @parm2 = 5, @parm3 = 6

What are the value of parameters passed to myproc in both the cases?

Multiple Choice

Stored procedures and Functions

Consider the following :

CREATE proc advance_range(@low money, @high money) WITH RECOMPILE ASSELECT * FROM dbo.titles where advance between @low and @highRETURN

Which of the following are valid ways of executing the above proc in case recompilation of query plan is required before executing?(Choose 2)

Page 31: SQL PDF Raviraj

124 Application Complex 1

125 Application Complex 1

126 Application Complex 2

Single Choice

Stored procedures and Functions

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 avg3GO

Assume that averagebookprice is a user defined scalar function that returns a value of 100.09 for 'computers' which of the following is a correct statement?

Single Choice

Stored procedures and Functions

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 returns a value of 100.09 for 'computers' which of the following is a correct statement?

Multiple Choice

Stored procedures and Functions

Consider the following example of a multi-statement table valued function in which some important statements are missing:

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

Which of the following explains the missing statements to be included in above?(Choose 2)

Page 32: SQL PDF Raviraj

127 Application Complex 1

128 Application Complex 1

Single Choice

Stored procedures and Functions

Consider the following example of a multi-statement table valued function: CREATE FUNCTION averagepricebytype(@ price money = 0.0RETURNS @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 RETURNEND

Which of the following example is correct to invoke the above function?

Single Choice

Stored procedures and Functions

Consider the following example of a multi-statement table valued function: CREATE FUNCTION averagepricebytype(@ price money = 0.0RETURNS @table table(type varchar(12) null, avg_price money null)with schemabindingAS BEGIN Iinsert @table SELECT type, avg(isnull(price, 0)) as avg_price FROM titles GROUP BY type HAVING avg(isnull(price, 0) > @price RETURNEND

The following command is issued on the table 'titles' that is used in the function above:ALTER table titles alter column price smallmoney null

Which of the following happens upon executing the ALTER command?

Page 33: SQL PDF Raviraj

129 Application Complex 1

130 Application Complex 1

131 Application Complex 1

Single Choice

Stored procedures and Functions

Consider the following Function:

CREATE FUNCTION striptime(@datetimeval datetime)

RETURNS datetimeWITH RETURNS NULL ON NULL INPUTAS BEGIN DECLARE @dateval datetime SELECT @dateval = convert(char(10), isnull@datetimeval), getdate()), 110) RETURN @datevalEND

Which of the following happens when the above function is invoked with NULL input?

Single Choice

Stored procedures and Functions

Consider the following function creation:

CREATE FUNCTION dbo.getonlydate()RETURNS datetimeasBEGIN DECLARE @date datetime SET @date = dbo.striptime(getdate()) RETURN @dateEND

Assume 'striptime' is another function already created.

Which of the following statement is correct for the above create function?

Single Choice

Stored procedures and Functions

Consider the following function creation:

CREATE FUNCTION dbo.getonlydate()RETURNS datetimeasBEGIN DECLARE @date datetime SET @date = getdate() RETURN @dateEND

Which of the following happens due to the use of non-deterministic function getdate() in the above UDF?

Page 34: SQL PDF Raviraj

132 Application Complex 1

133 Application Complex 1

Single Choice

Stored procedures and Functions

Consider the following function creation:

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

Which of the following happens due to the use of non-deterministic functions getdate() and rand() in the above UDF?

Single Choice

Stored procedures and Functions

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)) > @price)

Which of the following statement is correct for the function above?

Page 35: SQL PDF Raviraj

134 Application Complex 1Single Choice

Stored procedures and Functions

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 RETURNEND

Which of the following statement is correct for the above statements?

Page 36: SQL PDF Raviraj

135 Application Complex 1

136 Application Complex 1

Single Choice

Stored procedures and Functions

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)

Which of the following statement is correct for the above statements?

Single Choice

Stored procedures and Functions

Consider the creation of following stored procedure:

CREATE proc check_user_whoWITH EXECUTE AS 'Sunil'ASSELECT user_name() as 'User name applicable'GO

The following statements are executed:

SELECT user_name() as 'User name applicable'EXEC check_user_who

What is the result of SELECT in sequence when the above statements are executed?

Page 37: SQL PDF Raviraj

137 Application Complex 1

138 Application Complex 1

Single Choice

Stored procedures and Functions

Consider the following stored procedure creation:

CREATE proc sp_check_authorsASSELECT au_id, au_name, au_last_title FROM authors WHERE au_id > 1001GO

It so happens that the authors table is dropped and no longer exists in the database.What will be the outcome of the create procedure sp_check_authors as above?

Single Choice

Stored procedures and Functions

Consider the following stored procedure creation:

CREATE proc sp_check_authorsASSELECT au_id, au_name, au_last_title FROM authors WHERE au_id > 1001GO

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_authorsGO

What will be the outcome of the above create and execution statements?

Page 38: SQL PDF Raviraj

139 Application Complex 1

140 Application Complex 1

Single Choice

Stored procedures and Functions

Consider the following stored procedure creation:

CREATE proc sp_check_authorsAS BEGIN SELECT au_id, au_name, au_last_title FROM authors WHERE au_id > 1001 RETURNGO

Now the following statements are issued :

EXEC sp_helptext sp_check_authorsGO

SELECT definition FROM sys.sql_modules WHERE object_id = object_id('sp_check_authors')GO

SELECT object_definition (object_id('dbo.sp_check_authors'))GO

What will be the outcome of the above statements issued?

Single Choice

Stored procedures and Functions

Consider the following statements:

ALTER PROC insert_items @item_id char(4),@item_name varchar(40)asBEGIN TRYINSERT INTO comp1.dbo.itemmaster(item_id, item_name)VALUES(@item_id, @item_name)print ‘New Item added’END TRYBEGIN CATCHexec error_handlerRETURN -101END CATCHRETURN 0

What is the return code if the following statement is executed?

EXEC insert_items ‘ABCDEFGH’, ‘Gear Assembly’

Page 39: SQL PDF Raviraj

141 Application Complex 1

142 Application Complex 1

Single Choice

Stored procedures and Functions

Consider the following statements:

ALTER PROC insert_items @item_id char(4),@item_name varchar(40)asBEGIN TRYINSERT INTO comp1.dbo.itemmaster(item_id, item_name)VALUES(@item_id, @item_name)print ‘New Item added’END TRYBEGIN CATCHexec error_handlerRETURN -101END CATCHRETURN 0

What is the return code if the following statement is executed and the operation is successful?

EXEC insert_items ‘9951’, ‘Gear Assembly’

Single Choice

Stored procedures and Functions

Consider the following statements:

CREATE PROC sales_till_date@title varchar(100), @ytd_sales int OUTPUTASSELECT @ytd_sales = ytd_sales FROM titles where title = @titleRETURN

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), @sales_upto_today

What is the outcome of executing as above?

Page 40: SQL PDF Raviraj

143 Application Complex 1Single Choice

Stored procedures and Functions

Consider the following statements:

Assume table 'titles' exists with following books only:

Life without fear My experiments with truthGone with the wind

CREATE PROC ytd_sales2 @title varchar(80)ASIF NOT EXISTS (SELECT * FROM titles WHERE title = @title) RETURN -111SELECT 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'GOEXEC @status = ytd_sales2 'Undefeated'GOEXEC @status = ytd_sales2 'Gone with the wind'IF @status = -111 PRINT 'No book with that name found'GO

How many times the message 'No book with that name found'' will be displayed for the above scenario?

Page 41: SQL PDF Raviraj

144 Application Complex 1

145 Application Complex 1

Single Choice

Stored procedures and Functions

Consider the following statements:

CREATE PROC pub_testASSELECT pub_id, pub_name, city, statecdinto ##tempfrom publisherswhere statecd in ('MH', 'AP', 'TN')

SELECT pub_id, pub_name, city, statecdinto #tempfrom publisherswhere statecd in ('MH', 'AP', 'TN')GO

The following sequence of execution statements are made:

EXEC pub_testGOSELECT * from ##temp -----1SELECT * from #temp -----2

EXEC pub_testGOSELECT * from ##temp ------3

What is the correct sequence of outcome on executing the SELECT statements marked 1,2 3 as above?

Single Choice

Stored procedures and Functions

Consider the following statements:

CREATE PROC pub_testASSELECT pub_id, pub_name, city, statecdinto ##tempfrom publisherswhere statecd in ('MH', 'AP', 'TN')

SELECT pub_id, pub_name, city, statecdinto #tempfrom publisherswhere statecd in ('MH', 'AP', 'TN')GO

The following sequence of execution statements are made:

EXEC pub_testGOSELECT * from ##temp ------- 1SELECT * from #temp ------- 2DROP table ##tempEXEC pub_testGOSELECT * from ##temp -------- 3

What is the correct sequence of outcome on executing the SELECT statements marked 1,2,3 as above?

Page 42: SQL PDF Raviraj

146 Application Complex 2

147 Application Complex 1

Multiple Choice

Stored procedures and Functions

Consider the following scenario example:

CREATE PROC find_books_by_type @typelist varchar(8000)ASEXEC('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

Which of the following are correct statements for the above scenario?(Choose 2)

Single Choice

Stored procedures and Functions

Consider the following Stored procedures created:

CREATE PROC get_titles_data_by_price(@flag tinyint, @value money)AS select * from titles where price = @valueGOCREATE PROC get_titles_data_by_advance(@flag tinyint, @value money)AS select * from titles where advance = @valueGOCREATE PROC get_titles_data(@flag tinyint, @value money)ASif @flag = 1 exec get_titles_data_by_price @value else exec get_titles_data_by_advance @value

Which of the following stored procedure is functionally equivalent to the above set of stored procedures?

Page 43: SQL PDF Raviraj

148 Application Complex 1

149 Application Complex 1

Single Choice

Stored procedures and Functions

Consider the following statements:

CREATE PROC myproc @parm1 int1, @parm2 int, @parm3 intAS----processing done hereRETURN

The above PROC is executed twice as below:1) EXEC myproc 2) EXEC myproc @parm1 = 6

What is the outcome of executing the above ?

Single Choice

Stored procedures and Functions

Consider the following stored procedures:

CREATE proc main_procASexec sub_proc1exec sub_proc3exec sub_proc2returngo

CREATE proc sub_proc1ASexec sub_proc2go

CREATE proc sub_proc2ASexec proc sub_proc3return

CREATE proc sub_proc3ASexec sub_proc1 return

What will be the outcome upon invoking EXEC main_proc?

Page 44: SQL PDF Raviraj

150 Application Complex 1

151 Single ChoiceKnowledge Easy Transactions and XML Support in SQL Server 1

152 Knowledge Easy 1

153 Average 1

154 Average 1

155 Average 1

156 Average 1

157 Average 1

Single Choice

Stored procedures and Functions

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

Which of the following is the correct way to call the above stored procedure and pass values?

Which of the following is the Highest isolation level in SQL Server 2005?

Single Choice

Transactions and XML Support in SQL Server

Distributed queries allow you to collect and manipulate data from __________________________

Single Choice

Comprehension

Transactions and XML Support in SQL Server

You are writing a distributed query to query data from another SQL Server database. What is the fully qualified naming convention?

Single Choice

Comprehension

Transactions and XML Support in SQL Server

You are writing a distributed query to query data from an Access database. What is the fully qualified naming convention?

Single Choice

Comprehension

Transactions and XML Support in SQL Server

A distributed transaction is encompassing three different database serves. At the end of prepare phase in a two-phase commit, two servers reported successful prepare while one reported failure to prepare. How would the transaction manager respond?

Single Choice

Comprehension

Transactions and XML Support in SQL Server

Consider the following scenario. Your SQL server has a link to an Oracle database Ora_db running on Ora_linked_server. The schema definition of Ora_db has undergone a change. What will be the impact?

Single Choice

Comprehension

Transactions and XML Support in SQL Server

Which of the following the datasource must conform to in order to be a linkedserver?

Page 45: SQL PDF Raviraj

158 Average 1

159 Average 1

160 Average 1

161 True or False Average 1

162 Average 1

163 True or False Average 1

164 Application Easy 1

Single Choice

Comprehension

Transactions and XML Support in SQL Server

Which of the following is the use of sp_linkedservers command?

Single Choice

Comprehension

Transactions and XML Support in SQL Server

For which of the following is a two-phase commit, consisting of prepare and commit used?

Single Choice

Comprehension

Transactions and XML Support in SQL Server

Which of the following is correct for a shared lock?

Comprehension

Transactions and XML Support in SQL Server

A transaction attempting to modify data on a row or page on which a shared lock is placed can acquire an exclusive lock on the resource. State True or False.

Single Choice

Comprehension

Transactions and XML Support in SQL Server

When a SELECT * command is executed on a table, when is the shared lock on the first row released?

Comprehension

Transactions and XML Support in SQL Server

A transaction attempting to modify data on a row or page on which a shared lock is placed can acquire an update lock on the resource. State True or False.

Single Choice

Transactions and XML Support in SQL Server

Consider the following scenario:

A Table 'book' has the following recordsid title--- ------2 Catch-223 Roses in December4 My experiments with Truth

Assume a default isolation level of 'READ COMMITTED' for the following commands.

User1 has issued the following commandsBEGIN TRANSELECT title FROM book where id = 2;

User2 has now issued the following commandsSELECT title FROM book where id = 2;

What will be the outcome?

Page 46: SQL PDF Raviraj

165 Application Easy 1

166 Application Easy 1

Single Choice

Transactions and XML Support in SQL Server

Consider the following scenario:

A Table 'book' has the following recordsid title--- ------2 Catch-223 Roses in December4 My experiments with Truth

Assume a default isolation level of 'READ COMMITTED' for the following commands.

User1 has issued the following commandsBEGIN TRANSELECT title FROM book WITH (UPDLOCK) where id = 2;

User2 has now issued the following commandsSELECT title FROM book where id = 2;

What will be the outcome?

Single Choice

Transactions and XML Support in SQL Server

Consider the following scenario:

A Table 'book' has the following recordsid title--- ------2 Catch-223 Roses in December4 My experiments with Truth

Assume a default isolation level of 'READ COMMITTED' for the following commands.

User1 has issued the following commandsBEGIN TRANSELECT title FROM book WITH (UPDLOCK) where id = 2;

User2 has now issued the following commandsSELECT title FROM book WITH (UPDLOCK) where id = 2;

What will be the outcome?

Page 47: SQL PDF Raviraj

167 Application Easy 1

168 Application Easy 1

Single Choice

Transactions and XML Support in SQL Server

Consider the following scenario:

A Table 'book' has the following recordsid title--- ------2 Catch-223 Roses in December4 My experiments with Truth

Assume a default isolation level of 'READ COMMITTED' for the following commands.

User1 has issued the following commandsBEGIN TRANSELECT title FROM book WITH (UPDLOCK) where id = 2;

User2 has now issued the following commandsSELECT title FROM book WITH (UPDLOCK) where id = 3;

What will be the outcome?

Single Choice

Transactions and XML Support in SQL Server

Consider the following scenario:

A Table 'book' has the following recordsid title--- ------2 Catch-223 Roses in December4 My experiments with Truth

Assume a default isolation level of 'READ COMMITTED' for the following commands.

User1 has issued the following commandsBEGIN TRANSELECT title FROM book where id = 2;

User2 has now issued the following commandsUPDATE book SET title = 'Roses in December, Second edition' WHERE id = 2

What will be the outcome?

Page 48: SQL PDF Raviraj

169 Application Easy 1

170 Application Easy 1

Single Choice

Transactions and XML Support in SQL Server

Consider the following scenario:

A Table 'book' has the following recordsid title--- ------2 Catch-223 Roses in December4 My experiments with Truth

Assume a default isolation level of 'READ COMMITTED' for the following commands.

User1 has issued the following commandsBEGIN TRANUPDATE book SET title = 'Roses in December, Second edition' WHERE id = 2

User2 has now issued the following commandsSELECT title FROM book WHERE id = 2

What will be the outcome?

Single Choice

Transactions and XML Support in SQL Server

Consider the following scenario:

A Table 'book' has the following recordsid title--- ------2 Catch-223 Roses in December4 My experiments with Truth

Assume a default isolation level of 'READ COMMITTED' for the following commands.

User1 has issued the following commandsBEGIN TRANSELECT title FROM book WITH (UPDLOCK, HOLDLOCK) WHERE id = 2

User2 has now issued the following commandsSELECT title FROM book WHERE id = 2

What will be the outcome?

Page 49: SQL PDF Raviraj

171 Application Easy 1

172 Application Easy 1

Single Choice

Transactions and XML Support in SQL Server

Consider the following scenario:

A Table 'book' has the following recordsid title--- ------2 Catch-223 Roses in December4 My experiments with Truth

Assume a default isolation level of 'READ COMMITTED' for the following commands.

User1 has issued the following commandsBEGIN TRANSELECT title FROM book WITH (UPDLOCK, HOLDLOCK)

User2 has now issued the following commandsINSERT INTO book VALUES(5, 'Harry Potter and the Half-blood Prince')

What will be the outcome?

Single Choice

Transactions and XML Support in SQL Server

Consider the following scenario:

A Table 'book' has the following recordsid title--- ------2 Catch-223 Roses in December4 My experiments with Truth

Assume a default isolation level of 'READ COMMITTED' for the following commands.

User1 has issued the following commandsBEGIN TRANSELECT title FROM book WITH (UPDLOCK, HOLDLOCK) WHERE title like '%experiments%'

User2 has now issued the following commandsINSERT INTO book VALUES(6, 'Harry Potter and the Half-blood Prince')

What will be the outcome?

Page 50: SQL PDF Raviraj

173 Application Easy 1

174 Application Average 1

Single Choice

Transactions and XML Support in SQL Server

Consider the following scenario:

A Table 'book' has the following recordsid title--- ------2 Catch-223 Roses in December4 My experiments with Truth

Assume a default isolation level of 'READ COMMITTED' for the following commands.

User1 has issued the following commandsBEGIN TRANDELETE FROM book WHERE title like '%experiments%'

User2 has now issued the following commandsINSERT INTO book VALUES(6, 'Harry Potter and the Half-blood Prince')

What will be the outcome?

Single Choice

Transactions and XML Support in SQL Server

Consider the following scenario:

A Table 'book' has the following recordsid title--- ------2 Catch-223 Roses in December4 My experiments with Truth

Assume a Isolation level of 'READ_COMMITTED_SNAPSHOT' for the following commands.

User1 has issued the following commandsBEGIN TRANUPDATE book SET title = 'Roses in December, Second edition' WHERE id = 2

User2 has now issued the following commandsSELECT title FROM book WHERE id = 2

What will be the outcome?

Page 51: SQL PDF Raviraj

175 Application Average 1

176 Application Complex 1

177 Knowledge Easy 1

178 Application Average 1

Single Choice

Transactions and XML Support in SQL Server

Consider the following code:

BEGIN TRANDELETE FROM TABLE1BEGIN TRAN INSERT INTO TABLE2COMMITUPDATE TABLE3COMMIT

If the update to table3 failed, what will be the outcome?

Single Choice

Implementing Data integrity,Sub queries and Joins & T-SQL enhancements and functions

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.nameFROM player p,player mWHERE m.manager_id=p.id;

Statement 2:SELECT p.name,m.nameFROM player p,player mWHERE m.manager_id=p.id;

Which of the following is applicable for the above statements?

Single Choice

Transactions and XML Support in SQL Server

The new Isolation level in SQL Server 2005 wherein the values that are accessed remain the same till the transaction is Committed or Rolled back is called ____________.

Single Choice

Control flow constructs, Cursors

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 ENDEND

What is the outcome of executing the above?

Page 52: SQL PDF Raviraj

179 Application Average 1

180 Application Average 1

181 Application Average 1

Single Choice

Control flow constructs, Cursors

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 ENDEND

How many times the message 'I am here in one' will be printed on executing above?

Single Choice

Control flow constructs, Cursors

Consider the following statements as part of a stored procedure:

WAITFOR DELAY '02:00:22'BEGIN EXEC sp_process_total_oneWAITFOR TIME '02:00:22'BEGIN EXEC sp_process_total_twoEND

Supposing the above procedure is is run exactly at midnight, what is the expected outcome?

Single Choice

Control flow constructs, Cursors

Consider the following cursor processing:

DECLARE authors_cursor FORWARD_ONLY FORSELECT au_lname, au_fname FROM authorsORDER BY au_lname, au_fname

OPEN authors_cursor

FETCH FIRST FROM authors_cursorFETCH RELATIVE 3 FROM authors_cursorFETCH RELATIVE -2 FROM authors_cursor

CLOSE authors_cursorDEALLOCATE authors_cursor

(Assume that authors table has 200 author profiles)

What is the outcome of executing the above cursor statements?

Page 53: SQL PDF Raviraj

182 Application Average 1

183 Application Average 1

Single Choice

Control flow constructs, Cursors

Consider the following cursor processing:

DECLARE authors_cursor SCROLL FORSELECT au_lname, au_fname FROM authorsORDER BY au_lname, au_fname

OPEN authors_cursor

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

CLOSE authors_cursorDEALLOCATE authors_cursor

(Assume that authors table has 200 author profiles)

How many unique rows are retrieved upon executing the above cursor statements?

Single Choice

Control flow constructs, Cursors

Consider the following cursor processing statements:

DECLARE Employee_Cursor CURSOR READ_ONLY FORSELECT LastName, FirstName, status FROM dbo.EmployeesWHERE LastName like 'B%'

OPEN Employee_CursorFETCH NEXT FROM Employee_Cursor PRINT @@FETCH_STATUSWHILE @@FETCH_STATUS = 0BEGIN FETCH NEXT FROM Employee_Cursor PRINT @@FETCH_STATUSEND

CLOSE Employee_CursorDEALLOCATE Employee_Cursor

(Assume that the Employees table has 500 rows of employee data)

What is the value of @@FETCH_STATUS printed in the last print statement as per above?

Page 54: SQL PDF Raviraj

184 Application Average 1

185 Application Average 1

186 Application Average 1

Single Choice

Control flow constructs, Cursors

Consider the following cursor processing statements:

DECLARE @cba CURSORDECLARE 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 @cbaDEALLOCATE abc

In case the authors table had 100 author profiles, how many authors will get retrieved as per above processing?

Single Choice

Control flow constructs, Cursors

Consider the following cursor processing statements:

DECLARE Employee_Cursor CURSOR FAST_FORWARD FORSELECT LastName, FirstName, status FROM dbo.EmployeesWHERE LastName like 'B%' FOR UPDATE

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

CLOSE Employee_CursorDEALLOCATE Employee_Cursor

(Assume that the Employees table has 500 rows of employee data)

What is the outcome of the above cursor processing?

Single Choice

Control flow constructs, Cursors

Consider the following statements:

WHILE (1=1)BEGIN WAITFOR TIME '01:00' EXEC sp_update_stats RAISERROR('Statistics updated for database',1,1) WITH LOGEND

What is the outcome of the above?

Page 55: SQL PDF Raviraj

187 Application Average 2

188 Application Average 1

Multiple Choice

Control flow constructs, Cursors

Consider the following cursor processing statements:

DECLARE authors_cursor CURSOR FOR SELECT au_id, au_fname, au_lnameFROM authorsWHERE 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'ENDWHILE @@FETCH_STATUS = 0 BEGIN PRINT 'ATLEAST ONE ROW FOUND ' FETCH NEXT FROM authors_cursor ENDENDCLOSE authors_cursorDEALLOCATE authors_cursor

What is the message that gets printed in case the authors table does not have any rows satisfying the given condition?

Single Choice

Control flow constructs, Cursors

Consider the following cursor processing statements:

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

CLOSE @cbaDEALLOCATE abc

In case the authors table had 100 author profiles, how many authors will get retrieved as per above processing?

Page 56: SQL PDF Raviraj

189 Application Average 1Single Choice

Control flow constructs, Cursors

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' ENDFROM hr.department

Which of the following is correct equivalent to the above?

Page 57: SQL PDF Raviraj

190 Application Average 1Single Choice

Control flow constructs, Cursors

Consider the following scenario:

A proc is created as follows:

CREATE PROC cursor_proc @cursor CURSOR VARYING OUTPUTASDECLARE curs1 CURSOR GLOBAL FOR SELECT cast(title as varchar(30)) as title, pubdate from titlesset @cursor = curs1open curs1returngo

Now the following statements are executed:

DECLARE @curs CURSOR EXEC cursor_proc @cursor = @curs outputfetch curs1fetch @cursclose curs1deallocate curs1fetch @cursopen @cursgo

What is the outcome of the last fetch and open statements in above?

Page 58: SQL PDF Raviraj

191 Application Average 1Single Choice

Control flow constructs, Cursors

Consider the following scenario:

A proc is created as follows:

CREATE PROC cursor_proc @cursor CURSOR VARYING OUTPUTASDECLARE curs1 CURSOR GLOBAL FOR SELECT cast(title as varchar(30)) as title, pubdate from titlesset @cursor = curs1open curs1returngo

Now the following statements are executed:

DECLARE @curs CURSOR EXEC cursor_proc @cursor = @curs outputfetch curs1fetch @cursclose curs1deallocate curs1fetch @cursopen @cursfetch @cursclose @cursdeallocate @cursopen @cursgo

What is the outcome of the last fetch and open statements in the above statements?

Page 59: SQL PDF Raviraj

192 Application Average 1Single Choice

Control flow constructs, Cursors

Consider the following scenario:

A proc is created as follows:

CREATE PROC cursor_proc @cursor CURSOR VARYING OUTPUTASDECLARE curs1 CURSOR GLOBAL FOR SELECT cast(title as varchar(30)) as title, pubdate from titlesset @cursor = curs1open curs1returngo

Now the following statements are executed:

DECLARE @curs CURSOR EXEC cursor_proc @cursor = @curs outputfetch curs1fetch @cursclose curs1deallocate curs1deallocate cursfetch @cursopen @cursgo

What is the outcome of the last fetch and open statements in the above statements?

Page 60: SQL PDF Raviraj

193 Application Average 1

194 Application Average 1

Single Choice

Control flow constructs, Cursors

Consider the following scenario:

A proc is created as follows:

CREATE PROC cursor_proc @cursor CURSOR VARYING OUTPUTASDECLARE curs1 CURSOR GLOBAL FOR SELECT cast(title as varchar(30)) as title, pubdate from titlesset @cursor = curs1open curs1returngo

Now the following statements are executed:

DECLARE @curs CURSOR EXEC cursor_proc @cursor = @curs outputfetch curs1fetch @cursclose curs1deallocate curs1fetch @cursopen @cursfetch @cursclose @cursopen @cursgo

What is the outcome of the last fetch and open statements in the above statements?

Single Choice

Control flow constructs, Cursors

Consider the following cursor processing:

DECLARE authors_cursor FAST_FORWARD FORSELECT au_lname, au_fname FROM authorsORDER BY au_lname, au_fname

OPEN authors_cursor

FETCH NEXT FROM authors_cursorFETCH NEXT FROM authors_cursorFETCH NEXT FROM authors_cursorFETCH NEXT FROM authors_cursorCLOSE authors_cursorDEALLOCATE authors_cursor

(Assume that authors table has 200 author profiles)

What is the outcome of executing the above cursor statements?

Page 61: SQL PDF Raviraj

195 Application Average 1

196 Application Complex 1

Single Choice

Control flow constructs, Cursors

Consider the following cursor processing:

DECLARE authors_cursor FAST_FORWARD FORSELECT au_lname, au_fname FROM authorsORDER BY au_lname, au_fname

OPEN authors_cursor

FETCH NEXT FROM authors_cursorFETCH RELATIVE 7 FROM authors_cursorFETCH ABSOLUTE 5 FROM authors_cursorFETCH LAST FROM authors_cursorCLOSE authors_cursorDEALLOCATE authors_cursor

(Assume that authors table has 200 author profiles)

What is the outcome of executing the above cursor statements?

Single Choice

Control flow constructs, Cursors

Consider the following temporary stored procedure:CREATE PROCEDURE #use_tempASSELECT 1/0RETURN @@ERRORGO

The following statements are executed in a procedure:

IF NOT EXISTS(SELECT productid FROM production.product WHERE color = 'yellow' )BEGIN RETURNEND

SELECT productid FROM production.product WHERE color = 'yellow'DECLARE @ErrorCode INTEXEC @ErrorCode INT = #use_tempPRINT @ErrorCode

Assuming that there is no product with yellow color, what is the final outcome of executing as above?

Page 62: SQL PDF Raviraj

197 Application Complex 1Single Choice

Control flow constructs, Cursors

Consider the following temporary stored procedure:CREATE PROCEDURE #use_tempASSELECT 1/0RETURN @@ERRORGO

The following statements are executed in a procedure:

IF NOT EXISTS(SELECT productid FROM production.product WHERE color = 'yellow' )BEGIN RETURNEND

SELECT productid FROM production.product WHERE color = 'red'DECLARE @ErrorCode INTEXEC @ErrorCode INT = #use_tempPRINT @ErrorCode

Assuming that the database has products with red, yellow and blue colors, what is the final outcome of executing as above?

Page 63: SQL PDF Raviraj

198 Application Complex 1Single Choice

Control flow constructs, Cursors

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' ENDFROM hr.department

Which of the following is correct equivalent to the above?

Page 64: SQL PDF Raviraj

199 Application Complex 1

200 Application Complex 2

Single Choice

Control flow constructs, Cursors

Consider the following cursor processing:

The following procedures are created:

CREATE PROC sp_twoASSET NO COUNT ONFETCH C1RETURNGO

CREATE PROC sp_oneASSET NO COUNT ON DECLARE CURSOR C1 GLOBAL FOR SELECT titleid, type from titles OPEN C1 FETCH C1 EXEC sp_two CLOSE C1 DEALLOCATE C1GO(Assume that titles table has 100 book titles)

How many book titles are retrieved when proc sp_one is executed?

Multiple Choice

Control flow constructs, Cursors

Consider the following cursor processing:

The following procedures are created:

CREATE PROC sp_twoASSET NO COUNT ONFETCH C1RETURNGO

CREATE PROC sp_oneASSET NO COUNT ON DECLARE CURSOR C1 LOCAL FOR SELECT titleid, type from titles OPEN C1 FETCH C1 EXEC sp_two CLOSE C1 DEALLOCATE C1GO(Assume that titles table has 100 book titles)

What are the possible outcomes when proc sp_one is executed?(Choose 2)

Page 65: SQL PDF Raviraj

201 Application Complex 1Single Choice

Control flow constructs, Cursors

Consider the following cursor processing:

The following procedures are created:

CREATE PROC sp_twoASSET NO COUNT ONDECLARE CURSOR C1 LOCAL FOR SELECT au_id, au_name form authors OPEN C1 FETCH C1 CLOSE C1 DEALLOCATE C1RETURNGO

CREATE PROC sp_oneASSET NO COUNT ON DECLARE CURSOR C1 LOCAL FOR SELECT titleid, type from titles OPEN C1 FETCH C1 EXEC sp_two CLOSE C1 DEALLOCATE C1GO

What is the possible outcome when proc sp_one is executed?

Page 66: SQL PDF Raviraj

202 Application Complex 1Single Choice

Control flow constructs, Cursors

Consider the following cursor processing:

The following procedures are created:

CREATE PROC sp_twoASSET NO COUNT ONDECLARE CURSOR C2 GOBAL FOR SELECT au_id, au_name form authors OPEN C2 RETURNGO

CREATE PROC sp_oneASSET 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 RETURNGO(Assume that titles table has 100 book titles and authors table has 200 author profiles)What is the possible outcome when proc sp_one is executed?

Page 67: SQL PDF Raviraj

203 Application Complex 1Single Choice

Control flow constructs, Cursors

Consider the following cursor processing:

The following procedures are created:

CREATE PROC sp_twoASSET NO COUNT ONDECLARE CURSOR C2 GOBAL FOR SELECT au_id, au_name form authors OPEN C2 RETURNGO

CREATE PROC sp_oneASSET 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 RETURNGO

(Assume that titles table has 100 book titles and authors table has 200 author profiles)

The above is executed as follows:EXEC sp_oneGOFETCH C2GO

What is the possible outcome of the above execution?

Page 68: SQL PDF Raviraj

204 Application Complex 1Single Choice

Control flow constructs, Cursors

Consider the following cursor processing statements:

DECLARE @au_lname varchar(40), @au_fname varchar(20)

DECLARE authors_cursor CURSOR [FAST_FORWARD] FORSELECT au_lname, au_fname FROM authorsWHERE au_lname LIKE 'B%'

OPEN authors_cursor

FETCH NEXT FROM authors_cursorINTO @au_lname, @au_fname

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

CLOSE authors_cursorDEALLOCATE authors_cursorGO

In case the authors table has authors with following entries

au_lname au_fname

BHARAT IYERASHISH MALHOTRABIDYUT THAKURANISH MATREBALA SUBRAMANIAN

How many author names would have got printed at the end as per the cursor processing above?

Page 69: SQL PDF Raviraj

205 Application Complex 1

206 Average 1

Single Choice

Control flow constructs, Cursors

Consider the following cursor processing statements:

DECLARE authors_cursor CURSOR FOR SELECT au_id, au_fname, au_lnameFROM authorsWHERE state = 'UT'ORDER BY au_id

OPEN authors_cursor

IF @@CURSOR_ROWS = 0 BEGIN CLOSE authors_cursor DEALLOCATE authors_cursor RETURNEND

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 ENDENDCLOSE authors_cursorDEALLOCATE authors_cursor

What is the message that gets printed in case the authors table does not have any rows satisfying the given condition?

Single Choice

Comprehension

Transactions and XML Support in SQL Server

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' tag2.Create another file in which the column name must be the tag name for each value3.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

Per Rule 1, which of the following Centric method should Sham use to create the file?

Page 70: SQL PDF Raviraj

207 Average 1

208 Average 1

209 Average 1

210 Average 1

Single Choice

Comprehension

Transactions and XML Support in SQL Server

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' tag2.Create another file in which the column name must be the tag name for each value3.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

Per the Rule 2, which of the following Query should he use to create a file?

Single Choice

Comprehension

Transactions and XML Support in SQL Server

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' tag2.Create another file in which the column name must be the tag name for each value3.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

Which of the following query is the correct one for the rule 3?

Single Choice

Comprehension

Transactions and XML Support in SQL Server

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' tag2.Create another file in which the column name must be the tag name for each value3.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

Which clause helps in attaining the Xml namespace in the Root tag?

Single Choice

Comprehension

Transactions and XML Support in SQL Server

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 inside a Xml File.

Which of the following Encoding methods will you suggest?

Page 71: SQL PDF Raviraj

211 Average 1

212 Average 1

213 True or False Average 1

214 Average 1

215 Application Average 1

Single Choice

Comprehension

Transactions and XML Support in SQL Server

Consider the following two statements:

Staement 1: FOR XML RAW - does not support converting to XML file from a Join QueryStatement 2: FOR XML AUTO - supports converting to XML file from a join Query

Which of the following is applicable for the above statements?

Single Choice

Comprehension

Transactions and XML Support in SQL Server

Which of the folllowng FOR XML clause helps in controling the hierarchy of the xml result set generated?

Comprehension

Transactions and XML Support in SQL Server

Consider the following statement:

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

Query() method expects the pro-long part and body part when it is used along with 'WITH' statement .State TRUE or FALSE.

Single Choice

Comprehension

Transactions and XML Support in SQL Server

Which of the following methods() decompose the xml into a logical table similar to OPENXML?

Single Choice

Transactions and XML Support in SQL Server

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 not able to get both the tags.

What could be the reason for Rajiv not being able to get it?

Page 72: SQL PDF Raviraj

216 Application Average 1

217 Application Average 1

218 Application Average 1

219 Application Average 1

Single Choice

Transactions and XML Support in SQL Server

Consider the following scenario:

Jothi is working on a Xml File, which contains a tag named Email and its value is '[email protected]'.She needs to find out the tag which contains the value as '[email protected]' and replace it with another value.

Which of the following clause helps her in replacing the Value?

Single Choice

Transactions and XML Support in SQL Server

Consider the following statement:

SELECT * FROM SALES SJOINPRODUCT P ON P.PRODUCT_ID=S.PRODUCT_IDJOINPURCHASE PU ON PU.PRODUCT_ID=P.PRODUCT_IDFOR XML RAW('Child'),ELEMENTS

What is the outcome of the above statement?

Single Choice

Transactions and XML Support in SQL Server

Consider the following statement:

SELECT * FROM SALES JOINPURCHASE on PURCHASE.ID=SALES.IDFOR XML AUTO('ROW'),ELEMENTS

What will be the outcome of the above statement?

Single Choice

Transactions and XML Support in SQL Server

Consider the following statement:

SELECT * FROM SALES ORDER BY PRODUCTFOR XML RAW('ROW'),Elements XSINIL, ROOT('ROOT'),xmldata

Which of the following gives the error in the above statement?

Page 73: SQL PDF Raviraj

220 Application Average 1

221 Application Average 1

222 Application Average 1

Single Choice

Transactions and XML Support in SQL Server

Consider the following table:

SALES ID Contents 1 table 5 ChairHere 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></ROOT>

Identify the Query which gave the above Result?

Single Choice

Transactions and XML Support in SQL Server

Consider the following statement:

SELECT * FROM SALES JOINPURCHASE on PURCHASE.ID=SALES.IDFOR XML RAW('CHILD'),Elements XSINIL, ROOT('ROOT'),XMLSCHEMA

Which of the following is applicable for the above query?

Single Choice

Transactions and XML Support in SQL Server

Consider the following statement:

1.SELECT TOP 1 ID,CONTENTS FROM SALES 2.JOIN3.PURCHASE on PURCHASE.ID=SALES.ID4.FOR XML RAW('CHILD'),Elements XSINIL, ROOT('ROOT'),XMLSCHEMA5.BINARY

Which of the following can be added in the 5th line from the following which helps in Encoding the Binary data that is Supported in SQL Server 2005?

Page 74: SQL PDF Raviraj

223 Application Average 1

224 Application Average 1

225 Application Average 1

226 Application Average 1

Single Choice

Transactions and XML Support in SQL Server

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 for xml EXPLICIT

What is the result of the above statement?

Single Choice

Transactions and XML Support in SQL Server

Compare the following two statements:

1.SELECT * FROM ITEMFOR XML PATH('PRODUCT'),ROOT('PRODUCTITEM')

2.SELECT * FROM ITEM FOR XML RAW('PRODUCT'),ELEMENTS,ROOT('PRODUCTITEM')

Choose the correct option based on the output from the above two statements.

Single Choice

Transactions and XML Support in SQL Server

Consider the following statement:

SELECT * FROM ITEMFOR XML PATH('PRODUCT'),XSINIL,ROOT('PRODUCTITEM')

What is the outcome of the above statement?

Single Choice

Transactions and XML Support in SQL Server

Which of the following helps in taking a Column 'CONTENTS' value as a inner string in between the PRODUCTITEMS tag in FOR XML ?

Page 75: SQL PDF Raviraj

227 Application Average 1

228 Application Average 1

229 Application Average 1

Single Choice

Transactions and XML Support in SQL Server

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 ITEMFOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT')

What is the result of the above statement?

Single Choice

Transactions and XML Support in SQL Server

Which of the following statement helps in taking a Column 'CONTENTS' value as a Comment which is prefixed with 'Comments:' in FOR XML ?

Single Choice

Transactions and XML Support in SQL Server

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 table.

Which of the following node helps us in obtaining it?

Page 76: SQL PDF Raviraj

230 Application Average 1

231 Application Average 1

232 Application Average 1

Single Choice

Transactions and XML Support in SQL Server

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>

Which of the following helps in placing the CONTENTS column value as the value of contents attribute of the Tag 'Tagname'?

Single Choice

Transactions and XML Support in SQL Server

Consider the following statement:

SELECT address.query('http://schemas.microsoft.com';1.LET $pin=600220 2.FOR $pin IN//PIN 3.WHERE COUNT('/ADDRESS/PIN')>600004.ORDER BY XS:NAME(STRING($ADDRESS/NAME)) DESCRETURN<PIN>823456</PIN>)AS RESULTFROM CONTACT_DETAILS WHERE emp_id=10

Which of the following iterator or clause is not supported in SQL Server of the above numbered statement?

Single Choice

Transactions and XML Support in SQL Server

Which of the following is NOT supported in MODIFY() method?

Page 77: SQL PDF Raviraj

233 Average 1

234 Average 1

235 Average 1

236 True or False Average 1

237 Average 1

238 Average 1

Single Choice

Comprehension

Transactions and XML Support in SQL Server

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 are Compiled and optimized.

Which of the following is applicable for the above statements?

Single Choice

Comprehension

Transactions and XML Support in SQL Server

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 tablesStatement 2: While Identifying the Join clause, query optimizer treats SELF JOIN as a single table

Which of the following is applicable for the above statements?

Single Choice

Comprehension

Transactions and XML Support in SQL Server

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 operator.

Which of the following is applicable for above?

Comprehension

Transactions and XML Support in SQL Server

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. current date minus date of joining) and speed up the query processing.

State True or False.

Single Choice

Comprehension

Transactions and XML Support in SQL Server

How does Snapshot isolation differ from Read committed snapshot isolation?

Single Choice

Comprehension

Transactions and XML Support in SQL Server

How many isolation levels can be active for a user at any point of time?

Page 78: SQL PDF Raviraj

239 True or False Average 1

240 Average 1

241 Application Complex 1

Comprehension

Transactions and XML Support in SQL Server

If the same query or stored procedure is executed repeatedly, SQL server may not generate execution plan each time. State True or False.

Single Choice

Comprehension

Transactions and XML Support in SQL Server

For which of the following situation SQL server may determine that an execution plan needs to be recompiled?

Single Choice

Transactions and XML Support in SQL Server

Which of the following SELECT statement will execute the fastest?

Page 79: SQL PDF Raviraj

242 Application Complex 1

243 Application Complex 1

Single Choice

Transactions and XML Support in SQL Server

Consider the following sequence of operations from two users :

User 1 -SET TRANSACTION ISOLATION LEVEL SNAPSHOTgobegin transelect * from bookgoId Title--- ------2 Catch-223 Roses in December

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

User 1 -

update book set Title = ‘My Experiments with Truth’where id = 3go

What will be the outcome?

Single Choice

Transactions and XML Support in SQL Server

Consider the following T-SQL statement :

SELECT * FROM EMP_DETAILS INNER JOINEMP_SALARYDETAILSONEMP_DETAILS.EMP_ID=EMP_SALARYDETAILS.EMPIDWHERE EMPID=1001 OR EMPID =1002

Identify the order of optimization of the following clausesa.INNER JOINb.WHEREc.OR

Page 80: SQL PDF Raviraj

244 Application Complex 1

245 Application Complex 1

Single Choice

Transactions and XML Support in SQL Server

You are creating a procedure that will update two tables within a transaction. The code looks similar to the following: 1 BEGIN TRANSACTION23 BEGIN TRY4 UPDATE . . .56 END TRY78 BEGIN CATCH9 IF . . .1011 END CATCH12

Give the line number, where the ROLLBACK statement would normally be placed?

Single Choice

Transactions and XML Support in SQL Server

You are creating a procedure that will update two tables within a transaction. The code looks similar to the following: 1 BEGIN TRANSACTION23 BEGIN TRY4 UPDATE . . .56 END TRY78 BEGIN CATCH9 IF . . .1011 END CATCH12

Give the line number, where the COMMIT statement would normally be placed?

Page 81: SQL PDF Raviraj

246 Application Complex 1

247 Application Complex 1

Single Choice

Transactions and XML Support in SQL Server

Consider the following stored procedure:

1 begin tran2 update account set balance = balance - 1000 where account_number = 123 3 if @@error != 04 begin5 rollback tran6 return7 end8 update account set balance = balance + 1000 where account_number = 4569 if @@error != 010 begin11 rollback tran12 return13 end14 commit tran

If error code in line 9 is 12, what will be the outcome?

Single Choice

Transactions and XML Support in SQL Server

Consider the following stored procedure -

1 begin tran add_book2 insert book (id, name) values (2, ‘SQL for dummies’)3 if @@error = 500004 begin5 rollback tran add_book6 return7 end8 save tran keep_the_first09 insert book (id, name) values (3, ‘20 immutable laws of leadership’)10 if @@error = 5000011 begin12 rollback tran keep_the_first13 end14 commit tran

If the error code returned by line 10 is 50000, what will be the outcome?

Page 82: SQL PDF Raviraj

248 Application Complex 1

249 Application Complex 1

Single Choice

Transactions and XML Support in SQL Server

Consider the following stored procedure -

1 begin tran add_book2 insert book (id, name) values (2, ‘SQL for dummies’)3 if @@error = 500004 begin5 rollback tran add_book6 return7 end8 save tran keep_the_first09 insert book (id, name) values (3, ‘20 immutable laws of leadership’)10 if @@error = 5000011 begin12 rollback tran keep_the_first13 end14 commit tran

If the error code returned by line 3 is 50000, what will be the outcome?

Single Choice

Transactions and XML Support in SQL Server

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 of 'INDIA' ,what will be the output of the above stored procedure while creating/executing the procedure?

Page 83: SQL PDF Raviraj

250 Application Complex 1Single Choice

Transactions and XML Support in SQL Server

Consider the following statement:

DECLARE @XMLVAR XMLSET @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('SNAME') AS node, XMLTABLE.XMLCOLUMN.VALUE('STATE[1]/@SNO','CHAR(1)') AS STATE_CODEFROM @XMLVAR.nodes('/INDIA/STATES') AS XMLTABLE(xmlcolumn)

What is the result of the above statement?

Page 84: SQL PDF Raviraj

TRUE FALSE Y

Statement 1 is true, 2 is false Y Statement 1 is false, 2 is true

Y Y

Y Y Y

Statement 1 is true, 2 is false Statement 1 is false, 2 is true Y

Y Y

Both Statements 1 and 2 are true

Both Statements 1 and 2 are false

Filegroups apply only to data files and not log files

A data file can spread across multiple filegroups.

Once a data file is added to a database, it cannot be moved to another filegroup

There is no limit to the number of filegroups that can be created for a database

Database files should have sufficient space for growth

Data and log files should be placed on the same disk drive to maximise performance

Choose a common location or directory to keep the database files to keep things organised

The path specified for locating the database files should exist before creating a database

Both Statements 1 and 2 are true

Both Statements 1 and 2 are false

It can be accessed by multiple connections

It is automatically deleted when the connection is closed

The procedure remains active even after the connection is closed

It can be executed only by the connection that created it

Page 85: SQL PDF Raviraj

Y Y

Statement 1,2 and 3 are true Y

Y Y

Statement 1 is true, 2 is false Statement 1 is false, 2 is true Y

Local variables Function Y Expression Y

Local temporary tables created in a stored procedure are automatically dropped when the stored procedure exits.

Global temporary tables created in a stored procedure are unavailable immediately after the stored procedure exits

Global temporary tables are not available if the user session in which they were created disconnects from the SQL Server.

If a sub procedure referenced a temporary table created externally, a temporary table with the same name and structure has to exist at the time the stored procedure is created.

Statement 1 is true, 2 and 3 are false

Statement 2 and 3 are true, 1 is false

Statements 2 is true, 1 and 3 are false

The stored procedure name begins with sp_.

The stored procedure resides in a Resource database

These are generally more useful to end users than DBAs.

All the available system stored procedures are fully documented

Both Statements 1 and 2 are true

Both Statements 1 and 2 are false

Constant values

Page 86: SQL PDF Raviraj

Scalar function Y In-line table valued function

Statement 1 is true, 2 is false Statement 1 is false, 2 is true Y

Y

Y

Multi-statement table valued function

None of the listed options

Both Statements 1 and 2 are true

Both Statements 1 and 2 are false

A standard T-SQL stored procedure

A T-SQL stored procedure that uses a cursor

A CLR-integrated stored procedure

A CLR-integrated stored procedure that uses a cursor

Severity 20 or higher errors that do not result in closing of a connection

Errors with severity 10 or less that are warnings and informational messages

Compile errors or object name resolution errors that happen during deferred name resolution

Severity 20 or higher errors that results in closing of a connection

Page 87: SQL PDF Raviraj

Y

Scalar function In-line table valued function Y

Improved Security Precompiled Execution Y

Y Y

Y Y

Statement 1 is true, 2 is false Statement 1 is false, 2 is true Y

STATIC Y DYNAMIC KEYSET

FETCH SECOND FETCH ABSOLUTE 2 Y

Declare statements to define variables and cursors that are local to the function

EXECUTE statements that call an extended stored procedure

All of the listed options

Multi-statement table valued function

None of the listed options

Automatic Execution

Reuse Of Code

The stored procedure does not perform update operations on tables, except against table variables

The stored procedure has dynamic SQL statements executed via the EXECUTE statement

The stored procedure returns no more than a single result set

The stored procedure has multiple SELECT statements and uses cursors

Drop the procedure using DROP and re-create a new one using CREATE command

Create a new procedure with the same name using CREATE command

Modify the procedure using ALTER command

Drop the procedure using DROP command and modify using ALTER

Both Statements 1 and 2 are true

Both Statements 1 and 2 are false

FAST_FORWARD

FETCH RELATIVE 2

None of the listed options

Page 88: SQL PDF Raviraj

Statement 1 is true, 2 is false Statement 1 is false, 2 is true Y

Statement 1 is true, 2 is false Y Statement 1 is false, 2 is true

Statement 1 is true, 2 is false Statement 1 is false, 2 is true Y

Y OPEN contact_cursor Y Y

Both Statements 1 and 2 are true

Both Statements 1 and 2 are false

Both Statements 1 and 2 are true

Both Statements 1 and 2 are false

Both Statements 1 and 2 are true

Both Statements 1 and 2 are false

FETCH NEXT FROM contact_cursor

DEALLOCATE contact_cursor

CLOSE contact_cursor

Page 89: SQL PDF Raviraj

Local Scroll Y Global Scroll_locks

TRUE Y FALSE

Y

FIRST Y NONE Y ANY LAST Y

Y

Using Stored procedures Y Defining indexes Y

Smallest unit of data storage Y

Y

TRUE Y FALSE

INSTEAD trigger does not support recursion

Only one INSTEAD of trigger can be defined for each action on a given table

A table cannot have an INSTEAD of trigger and FOREIGN KEY constraint with CASCADE defined for the same action

All of the listed options

Queries that do not return large result sets

Columns that are frequently used in the WHERE clause that return exact matches

Coumns that have many distinct values

All of the listed options

Defining Foreign key constraints

Defining views

Automatically created at the time of creating a table

Allows an application program to find specific data without scanning through the entire table

contains information about modifications carried out in the database

Under msdb database in sysxlogins tables

Under tempdb database in sysxlogins tables

Under Master database in sysxlogins tables

None of the listed options

Page 90: SQL PDF Raviraj

View temp table Y Extension

msdb model master tempdb Y

Y Indexed views aid in optmizing performanceY

Y

Nested subquery Correlated subquery Y

Union Subquery Join Role Y

SELECT INTO Y UNION SUBQUERY JOIN

User Defined Type

An indexed view is any view that has a clustered index defined on it

The indexed view is a logical entity and is not materialized in the database

You can create only one index on a view

GRANT select ON dept TO ALL_ USERS

GRANT QUERY ON dept TO ALL_USERS

GRANT select ON dept TO PUBLIC;

None of the listed options

Plain Subquery

Join Subquery

Page 91: SQL PDF Raviraj

IF..ELSE WHILE Y CASE

Data Integrity Domain Integrity Y

Referential Integrity Y Domain Integrity

Data Integrity Domain Integrity Y

None of the listed options

User Defined Integrity

Entity Integrity

User Defined Integrity

Entity Integrity

User Defined Integrity

Entity Integrity

Page 92: SQL PDF Raviraj

Y

Create a view on the four tables. Create an index on the view

Denormalize the database design if possible

Further normalize the table

Define Referential Integrity constraints so that data can be referenced faster

Page 93: SQL PDF Raviraj

Y

Y

UPDATE new_employees SET name = (Select last_name || first_name FROM employees Where employee_id =180)

UPDATE new_employees SET name = (SELECT last_name || first_name FROM employees) WHERE employee_id = 180;

UPDATE new_employees SET name = (SELECT last_name || first_name FROM employees WHERE employee_id =180) WHERE employee_id =(SELECT employee_id FROM new employees)

None of the listed options

A subquery must be enclosed in parenthesis

A subquery must be put in the right hand side of the comparison operator

A subquery cannot contain a ORDER-BY clause

A query should not contain more than one sub-query

Page 94: SQL PDF Raviraj

Insert Y Changing Column Name Y Y

Y

Increasing column length

Modify datatype

Creates four partitions 1) for data before 19932) for data of 1993 3) for data of 1994 4) for data of 1995 or later

Creates three partitions 1) for data of 1993 2) for data of 1994 3) for data of 1995 or later

Creates four partitions 1) for data before 19932) for data of 1993 3) for data of 1994 4) for data of 1995

Creates three partitions 1) for data of 1993 or prior to 1993 2) for data of 1994 3) for data of 1995 or later

Page 95: SQL PDF Raviraj

Y

Y

SCHEMABINDING clause Y Y

It retrieves information of employees born after March 1, 1965 and who have been hired after february 1, 2007

It retrieves information of employees born after March 1, 1965

It retrieves information of employees who have been hired after february 1, 2007

It retrieves information of employees born on or after March 1, 1965 and who have been hired on or after after february 1, 2007

IsIndexable is a property that returns 1 if the view has atleast one index, and 0 if there is no index created on the view

IsIndexable is a property that returns 1 if an index can be created on the view, and 0 if it is not indexable.

IsIndexable is a property that returns 0 if an index can be created on the view, and 1 if it is not indexable.

IsIndexable is a property that returns 0 if an index can be created on the view, and 1 if it is not indexable.

FOR CREATION OF INDEX clause

UNIQUE clause in the CREATE SCHEMA line

Database qualifier for each table

Page 96: SQL PDF Raviraj

Adds files with new names Adds files to folders Y

Y

Y None of the listed options

Y Y

Y

Adds files to filegroups

Adds files to database

Select * from prod.product_detailswhere unit_of_measure = 'KG'OPTION(NOEXPAND VIEWS)

Select * from prod.product_detailswhere unit_of_measure = 'KG'OPTION(EXPAND VIEWS)

Select * from prod.product_detailswhere unit_of_measure = 'KG'

Select * from prod.product_detailswhere unit_of_measure = 'KG'OPTION(EXPAND INDEXES)

Modifies the name of the Employee database log file

Alters the Employee database structure

Moves the log file of the Employee database to the root of the C: drive

It is an error and invalid data type

It could be an user defined data type

It is a valid basic data type supported

None of the listed options

Creates partitioned view CustPS1 on table customers_p1

Creates Customers_p1 table in file group custPS1

Creates Customers_p1 table in partition scheme custPS1 and column order_dt is used for partitioning

None of the listed options

Page 97: SQL PDF Raviraj

Y

Y

Y

Y

Creates table Table1 in filegroup userdata_FG and creates a clustered index in filegroup userdata_FG

Creates table Table1 in filegroup userdata_FG and creates a clustered index in default filegroup

Creates table Table1 in filegroup userdata_FG and creates a clustered index in filegroup userindex_FG

None of the listed options

ALTER TABLE emp ALTER COLUMN emp_address VARCHAR(40) NULL

ALTER TABLE emp ALTER COLUMN emp_address VARCHAR(40) NOT NULL

ALTER COLUMN emp_address of TABLE emp VARCHAR(40) NULL

ALTER COLUMN emp_address of TABLE emp VARCHAR(40) NOT NULL

ALTER TABLE emp ALTER COLUMN emp_address nchar NULL

ALTER COLUMN emp_address of TABLE emp nchar NULL

ALTER COLUMN emp.emp_address nchar NULL

None of the listed options

ALTER TABLE emp ADD emp_gender char NOT NULL

ALTER TABLE ADD emp.emp_gender char NOT NULL

ALTER TABLE emp ADD emp.emp_gender char NOT NULL AFTER emp_name

None of the listed options

ALTER TABLE ADD emp.emp_gender char NOT NULL

ALTER TABLE emp ADD emp_gender char NOT NULL

ALTER TABLE emp ADD AT END emp_gender char NOT NULL

None of the listed options

Page 98: SQL PDF Raviraj

Y

Y

Y

Creates a simple view successfully.

Create fails because derived columns are not allowed in SELECT

Create fails because derived columns in SELECT should have a name or alias associated with it

Creates an indexed view successfully.

Creates a simple view successfully.

Create fails because derived columns are not allowed in SELECT

Create fails because ORDER BY clause is not allowed in this statement

Creates an indexed view successfully.

Creates a simple view, and retrieves maximum of five records based on the given criteria

Create fails because the CREATE statement does not have ORDER BY clause

Creates a simple view and retrieves minimum of five records based on the criteria

Create fails because GROUP BY clause is not allowed in CREATE statement

Page 99: SQL PDF Raviraj

Y

Y

Y

Y

The CREATE statement fails because CHECK OPTION is invalid for create view

The CREATE and the UPDATE statements go through successfully

The CREATE statement goes through but UPDATE statement fails

None of the listed options

The CREATE statement fails

The CREATE and the UPDATE statements go through successfully

The CREATE statement goes through but UPDATE statement fails

None of the listed options

CREATE VIEW sales_vu ASSELECT territoryid, sum(totaldue) 'Totalsales'FROM sales.salesorderGROUP BY territoryidORDER BY territoryid

CREATE VIEW sales_vu ASSELECT territoryid, sum(totaldue) 'Totalsales'FROM sales.salesorderORDER BY territoryid

CREATE VIEW sales_vu ASSELECT territoryid, sum(totaldue) 'Totalsales'FROM sales.salesorderGROUP BY territoryid

None of the listed options

Two clustered indexes idx1 and idx2 will be created on emp table

Only one clustered index idx1 will be created on emp table

Only one clustered index idx2 will be created on emp table

No index will be created on emp table

Page 100: SQL PDF Raviraj

Y

Y

Y

Y

Creates non-clustered indexes idx1 on empname and idx2 on empdob, both in descending order

Creates clustered index idx1 on empname and non-clustered index idx2 on empdob, both in ascending order

Creates non-clustered indexes idx1 on empname and idx2 on empdob, both in ascending order

Creates clustered index idx1 on empname and non-clustered index idx2 on empdob, both in descending order

Create a unique clustered index on emailid

Create a unique non-clustered index on emailid

Create a non unique clustered index on emailid

This requirement cannot be met by creating indexes

It concatenates empaddress to empname to form the index

It creates index values for empname only if address is present(not null)

It includes empaddress in the leaf level pages of the index

None of the listed options

The index idx1 is completely removed

The index idx1 is temporarily disabled

The index idx1 is permanently disabled

The statements end with execution error

Page 101: SQL PDF Raviraj

Y

Y

Y

The index idx1 gets recreated

The index idx1 is temporarily disabled

The index idx1 is permanently disabled

The statements end with execution error

It is a AFTER DML trigger that restricts addition of new users except with DBA privileges

It is an INSTEAD OF trigger that restricts addition of new users except with DBA privileges

It is a DDL trigger that restricts creation of new user logins into a server

None of the listed options

Use ALTER command and disable the index using DISABLE clause and rebuild using REBUILD clause

Use ALTER command and rebuild the index using REBUILD clause

Use ALTER command and rebuild using REBUILD with ONLINE = ON clause

Rebuild is not possible when the table is updated 24*7

Page 102: SQL PDF Raviraj

Y

Y

The city for au_id = 1001 is changed to MUMBAI in authors table

The city for au_id = 1001 is set to NULL in authors table

The city for au_id = 1001 is not changed in the authors table

None of the listed options

A new row for au_id = 1001 is inserted with name = PRAKASH and city = MUMBAI

No row is added for au_id = 1001

A new row for au_id = 1001 is inserted with name = PRAKASH and city = NULL

None of the listed options

Page 103: SQL PDF Raviraj

Y

Y

A new row for au_id = 1001 is inserted with name = PRAKASH and city = NULL

No row is added for au_id = 1001

A new row for au_id = 1001 is inserted with name = PRAKASH and city = blank

None of the listed options

A new row for au_id = 1001 is inserted with name = PRAKASH and city = NULL

No row is added for au_id = 1001

A new row for au_id = 1001 is inserted with name = PRAKASH and city = blank

None of the listed options

Page 104: SQL PDF Raviraj

Y

Y

Select shows au_id = 1001 and au_name = 'Rajeev'

Select shows au_id = 1001 and au_name = 'Raghav'

Select shows au_id = 1001 and au_name as NULL

None of the listed options

Select shows au_id = 1001 and au_name = 'Rajeev'

Select shows au_id = 1001 and au_name = 'Raghav'

Select shows au_id = 1001 and au_name as NULL

Select shows au_id = 1001 and au_name = 'Raman'

Page 105: SQL PDF Raviraj

Y

Y

Y

The new column new_col is created and dropped on table titles

The new column new_col is created on table titles but drop fails

Creation of new column new_col on table titles itself fails

None of the listed options

The clustered index idx1 fails to create

The clustered index idx1 is created on titles table colum titlename and the event-specific information appears in the results pane

The clustered index idx1 is created on titles table colum titlename without any notification

None of the listed options

Directly use the UPDATE statement on the view to update columns from both the base tables

There is no solution to update the columns from both tables using the view

Create an INSTEAD of UPDATE Trigger on the view and update tables as part of trigger code

Create an AFTER Trigger on the view and update tables as part of trigger code

Page 106: SQL PDF Raviraj

Y

tr_1 , tr_4, tr_2, tr_3 Y tr_1, tr_5, tr_4, tr_3

The employee rows in table empgets deleted and the department row in dept table is then deleted

The employee rows in emp table alone get deleted

The department row in dept table alone gets deleted

The delete on dept table fails due to foreign key constraint and no further deletions take place on dept or emp table

tr_4, tr_1, tr_2, tr_3

tr_1, tr_2, tr_5, tr_3

Page 107: SQL PDF Raviraj

Only jobs table gets updated Y

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

It must be isolated It must be durable Y

ROLLBACK COMMIT SAVEPOINT All of the listed optionsY

COMMIT ROLLBACK Y ALTER SAVEPOINT

Read uncommitted Read Committed Serializable Y

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

XPATH XML Y XSD

2 4 3 Y 7

Transactional Replications Snapshot Replications Traditional ReplicationsY Merge Replications

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

processadmin setupadmin Y securityadmin serveradmin

Both the employees and jobs tables are updated

Only employees table gets updated

Both the jobs and employees tables are not updated

It must be sealed

None of the listed options

Repeatable Read

XTEMPLETS

Page 108: SQL PDF Raviraj

Y None of the listed options

Y

Y

Y

Y

Y

CREATE ROLE managerGRANT create table, create viewTO manager;GRANT manager TO BLACK, CLARK;

CREATE ROLE managerGRANT create table, create voewTO manager;GRANT manager ROLE TO BLACK, CLARK;

GRANT manager ROLE TO BLACK, CLARK;GRANT create table, create voewTO BLACK CLARK;

GENERATE SEQUENCE SE START WITH 30 ADD BY 20

CREATE SEQUENCE SE START WITH 30 ADD BY 20

CREATE SEQUENCE SE START WITH 30 INCREMENT BY 20

GENERATE SEQUENCE SE INITIATE WITH 30 INCREMENT BY 20

EmpNum column or ProjNum column can not have duplicate values

EmpNum and ProjNum columns can not be nullable

More than one column is not allowed for a primary key constraint

It is better to define two primary key constraints with EmpNum and ProjNum separately

All records in EMPLOYEE table belonging to that department are deleted

The Dept_id column in EMPLOYEE table belonging to that department is updated to spaces

The Dept_id in EMPLOYEE table belonging to that department is set to NULL

Update fails if there are any records in EMPLOYEE table for that Dept_id

The DEPARTMENT record is deleted but there is no update done on EMPLOYEE table

No update occurs and no error is given

An error is returned as data integrity is violated

It leads to unpredictable results

The DEPARTMENT record is deleted but there is no update done on EMPLOYEE table

The DEPARTMENT record is deleted and the Dept_id column in EMPLOYEE tabel is set to null values

The DEPARTMENT record is deleted and the Dept_id column in EMPLOYEE tabel is set to spaces

An error is returned as data integrity is violated

Page 109: SQL PDF Raviraj

1 2 3 Y 4

1 2 3 4 Y

Page 110: SQL PDF Raviraj

1 2 3 Y 4

Y

Y

The SELECT statement does not execute but stored procedure sp_process executes

The SELECT statement executes but stored procedure sp_process does not execute

Both SELECT and stored procedure sp_process fail to execute

Both SELECT and stored procedure sp_process execute successfully

With 1) The PROC runs successfully using the parameter values suppliedWith 2) The PROC runs successfully using the parameter values supplied

With 1) The PROC give error as the parameters are not supplied properlyWith 2) The PROC runs successfully using the parameter values supplied

With 1) The PROC runs successfully using the parameter values suppliedWith 2) The PROC gives error as the parameters are not supplied properly

With 1) The PROC gives error as the parameters are not supplied properlyWith 2) The PROC gives error as the parameters are not supplied properly

Page 111: SQL PDF Raviraj

Y

Y

2 times Y 16 times 32 times 31 times

ALTER DATABASE <database> SET TRUSTWORTHY ONgosp_configure 'clr enabled', 1goreconfigurego

ALTER DATABASE <database> SET TRUSTWORTHY ONgosp_configure 'clr enabled', 1go

ALTER DATABASE <database> SET TRUSTWORTHY ONgosp_configure 'clr'goreconfigurego

ALTER DATABASE <database> SET TRUSTWORTHY ON

sp_configure 'clr'

reconfigures

Use Dynamic SQL in stored procedures

Use Nested stored procedures

Use extended stored procedures

Drop the stored procedures that are not in use

Page 112: SQL PDF Raviraj

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

Gives execution error Y

Y

IF ERROR = 0

IF ERROR <> 0

Creates a new proc get_au_name and deletes the proc create_other_proc

Creates a new proc get_au_name

None of the listed options

The SELECT statement does not execute but stored procedure sp_process executes

The SELECT statement executes but stored procedure sp_process does not execute

Both SELECT and stored procedure sp_process fail to execute

Both SELECT and stored procedure sp_process execute successfully

Page 113: SQL PDF Raviraj

Y

Y

Y

Y Y

The SELECT statement does not execute but stored procedure sp_process executes

The SELECT statement executes but stored procedure sp_process does not execute

Both SELECT and stored procedure sp_process fail to execute

Both SELECT and stored procedure sp_process execute successfully

The sp_create_staff procedure is not created due to severe error

The sp_create_staff procedure is created with a warning error

The sp_create_staff procedure is created without any kind of errors

The sp_use_jobs procedure is automatically created before sp_create_staff procedure is created

With 1) parm1 = 0, parm2 = 0, parm3 = 0With 2) parm1 = 100, parm2 = 5, parm3 = 6

With 1) Gives error due to incorrect parameter passingWith 2) parm1 = 100, parm2 = 5, parm3 = 6

With 1) parm1 = 100, parm2 = 200, parm3 = 300With 2) parm1 = 100, parm2 = 5, parm3 = 6

With 1) parm1 = 100, parm2 = 200, parm3 = 300With 2) parm1 = 0, parm2 = 5, parm3 = 6

EXEC advance_range 2000 5000 WITH RECOMPILE

EXEC advance_range 2000 5000

EXEC advance_range 2000 5000 WITH NO RECOMPILE

EXEC advance_range 2000 5000 NOCOMPILE

Page 114: SQL PDF Raviraj

Y

Y

Y Y

avg1 will be 100.09, avg2 will be 100 and avg3 will be 100.10

avg1 will be 100.09, avg2 will be 100.09 and avg3 will be 100.09

avg1 will be 100, avg2 will be 100.09 and avg3 will be 100.10

avg1 will be 100.10, avg2 will be 100 and avg3 will be 100.09

avg1 will be displayed as 100

avg1 will be displayed as 100.09

There will be execution error in the statements

avg1 will be displayed as 100.10

Include BEGIN….END as wrappers around the statements the function contains.

Include the clause 'MULTI-STATEMENT TABLE' in the CREATE statement

Include DO….END as wrappers around the statements the function contains.

Define the structure of the table rowset that you are returning

Page 115: SQL PDF Raviraj

Y

The ALTER command fails Y The price column is changed

Select * from multi-statement table function averagepricebytype(15)

Select * from averagepricebytype(15)

Select * from averagepricebytype(15) using multi-statement table function

Select * from function averagepricebytype(15)

The price column is changed only if no user is using the averagepricebytype function when the ALTER command is issued

None of the listed options

Page 116: SQL PDF Raviraj

Y

Y

Y

The FUNCTION body gets executed and NULL is returned as result

The FUNCTION body does not get executed and the value of NULL is returned

The FUNCTION returns error if input is NULL

None of the listed options

The CREATE function is not valid and gives error

The CREATE function is valid but will give execution error that striptime is not found

The CREATE function is valid and will not give any execution error on existence of striptime function.

None of the listed options

The CREATE function is not valid and gives error

The CREATE function is valid but will give execution error because of use of non-deterministic function getdate()

The CREATE function is valid and will not give any execution error on use of getdate()

None of the listed options

Page 117: SQL PDF Raviraj

Y

Y

The CREATE function is not valid and gives error

The CREATE function is valid but gives execution error on use of rand()

The CREATE function is valid but gives execution error on use of getdate()

None of the listed options

It creates a valid in-line table valued function

Create fails because it is an invalid type of table valued function

Create fails because it is an invalid type of scalar function

None of the listed options

Page 118: SQL PDF Raviraj

YThe CREATE fails but ALTER succeeds

The CREATE succeeds but ALTER fails

Both CREATE and ALTER fails

CREATE and ALTER go through successfully

Page 119: SQL PDF Raviraj

Y

Y

The CREATE fails but ALTER succeeds

The CREATE succeeds but ALTER fails

Both CREATE and ALTER fails

CREATE and ALTER go through successfully

User name applicable - dboUser name applicable - Sunil

User name applicable - dboUser name applicable - dbo

User name applicable - SunilUser name applicable - dbo

User name applicable - SunilUser name applicable - Sunil

Page 120: SQL PDF Raviraj

Y

Y

The sp_check_authors procedure is not created due to severe error

The sp_check_authors procedure is created with a warning error

The sp_check_authors procedure is created without any kind of errors

The authors table is automatically created before sp_check_authors procedure is created

Both Create and execution fails

Create fails but execution goes through without errors

Both Create and execution goes through without errors

Create is successful but execution gives error

Page 121: SQL PDF Raviraj

Y

0 -101 Y NULL -1

The source code of the stored procedure sp_check_authors is displayed 2 times

The source code of the stored procedure sp_check_authors is displayed once

The source code of the stored procedure sp_check_authors is displayed once

The source code of the stored procedure sp_check_authors is displayed 3 times

Page 122: SQL PDF Raviraj

0 Y -101 NULL -1

Y

The year to date sales as picked up from the titles table will be correctly displayed for the book 'My experiments with truth'

The year to date sales as picked up from the titles table will not be correctly displayed for the book 'My experiments with truth'

The PROC will give error while executing

None of the listed options

Page 123: SQL PDF Raviraj

once twice none Y thrice

Page 124: SQL PDF Raviraj

Y

Y

1) The contents of temp table are correctly displayed2) The contents of temp table are correctly displayed3) Error message displayed

1) Error message displayed 2) The contents of temp table are correctly displayed3) Error message displayed

1) The contents of temp table are correctly displayed2) Error message displayed 3) Error message displayed

1) The contents of temp table are correctly displayed2) Error message displayed3) The contents of temp table are correctly displayed

1) The contents of temp table are correctly displayed2) The contents of temp table are correctly displayed3) Error message displayed

1) Error message displayed 2) The contents of temp table are correctly displayed3) Error message displayed

1) The contents of temp table are correctly displayed2) Error message displayed 3) Error message displayed

1) The contents of temp table are correctly displayed2) The contents of temp table are correctly displayed3) The contents of temp table are correctly displayed

Page 125: SQL PDF Raviraj

Y Y

Y

The nested stored procedure concept is used

Variable list of values can be passed into the stored procedure

It uses dynamic sql query within a stored procedure

Only three values can be passed into the stored procedure

CREATE PROC get_titles_data_by_price(@flag tinyint, @value money)AS exec get_titles_data @valueGOCREATE PROC get_titles_data_by_advance(@flag tinyint, @value money)AS exec get_titles_data @valueGOCREATE PROC get_titles_data(@flag tinyint, @value money)ASif @flag = 1 exec get_titles_data_by_price @valueelse exec get_titles_data_by_advance @value

CREATE PROC get_titles_data(@flag tinyint, @value money)ASSelect * from titles where price = @value or advance = @value

CREATE PROC get_titles_data(@flag tinyint, @value money)ASif @flag = 1 select * from titles where price = @valueelse select * from titles where advance = @value

None of the listed options

Page 126: SQL PDF Raviraj

Y

With 1) Gives error - Procedure 'myproc' expects parameter '@parm1', '@parm2', '@parm3' which was not supplied With 2) parameters passed: parm1 = 6, parm2 = 0, parm3 = 0

With 1) Gives error - Procedure 'myproc' expects parameter '@parm1' which was not supplied With 2) Gives error - Procedure 'myproc' expects parameter '@parm2' which was not supplied

With 1) parameters passed: parm1 = 0, parm2 = 0, parm3 = 0With 2) Gives error - Procedure 'myproc' expects parameter '@parm2' which was not supplied

With 1) parameters passed: parm1 = 0, parm2 = 0, parm3 = 0With 2) parameters passed: parm1 = 6, parm2 = 0, parm3 = 0

sub_proc1 will be executed only once

sub_proc2 will be executed 3 times

sub_proc3 will be executed 2 times

sub_proc1, sub_proc2, sub_proc3 will be executed 32 times each

Page 127: SQL PDF Raviraj

Y

Read uncommitted Read Committed Serializable Y

Y

Y

Y

Y

Y

Y

EXEC SelectByIdList @productIds='<Products><id>3</id><id>6</id><id>15</id></Products>'

EXEC SelectByIdList @productIds='P001'

EXEC SelectByIdList @productIds='P001' and productIds='P002'

EXEC SelectByIdList

Repeatable Read

more than one table in a database

multiple SQL Server databases on a server

multiple OLE DB datasources

None of the listed options

linked_server_name.database.owner.table

linked_server_name.database.table

linked_server_name…table

database.table

Access_server_name.database.owner.table

Access_server_name.owner.table

Access_server_name...table

None of the listed options

It sends a Rollback command to all three resource managers

It sends a rollback command to the server that reported a failure to prepare

Commit is issued as majority of servers reported successful prepare

Name of the server which failed to prepare, is logged for repair work by DBA

Ora_db is delinked from the SQL server

The changes of Ora_db are notified to the SQL server

The databases become semi-linked

None of the listed options

It must be a SQL Server 2005

It must be a database supplied by Microsoft (eg., Access, Excel)

It must be a OLE DB compliant data source

It must be a Relational Database

Page 128: SQL PDF Raviraj

Y

Y

Y

TRUE FALSE Y

After all the rows are read After the first row is read Y

TRUE Y FALSE

User2 will be blocked Y

It allows you to define a linked server on the local server

It allows you to display the list of linked servers defined on the local server

It allows you to specify a login id that links the servers

It activates the link between the servers

Transactions that might require a rollback

Transactions updating multiple tables

Distributed transactions

Transactions requiring user confirmation of update

It is a lock acquired by a process on the resources that it intends to modify

It is a lock acquired by a process on a resource prior to modifying it

It is lock acquired by a process on a resource for the duration of read

None of the listed options

After the second row is read

Only when the transaction is committed or rolled back

User2 will not be blocked and both will proceed

User1's transaction is blocked and user2 will proceed

There will be a deadlock

Page 129: SQL PDF Raviraj

User2 will be blocked Y

User2 will be blocked Y

User2 will not be blocked and both will proceed

User1's transaction is blocked and user2 will proceed

There will be a deadlock

User2 will not be blocked and both will proceed

User1's transaction is blocked and user2 will proceed

There will be a deadlock

Page 130: SQL PDF Raviraj

User2 will be blocked Y

User2 will be blocked Y

User2 will not be blocked and both will proceed

User1's transaction is blocked and user2 will proceed

There will be a deadlock

User2 will not be blocked and both will proceed

User1's transaction is blocked and user2 will proceed

There will be a deadlock

Page 131: SQL PDF Raviraj

User2 will be blocked Y

User2 will be blocked Y

User2 will not be blocked and both will proceed

User1's transaction is blocked and user2 will proceed

There will be a deadlock

User2 will not be blocked and both will proceed

User1's transaction is blocked and user2 will proceed

There will be a deadlock

Page 132: SQL PDF Raviraj

User2 will be blocked Y

User2 will be blocked Y

User2 will not be blocked and both will proceed

User1's transaction is blocked and user2 will proceed

There will be a deadlock

User2 will not be blocked and both will proceed

User1's transaction is blocked and user2 will proceed

There will be a deadlock

Page 133: SQL PDF Raviraj

User2 will be blocked Y

User2 will be blocked Y

User2 will not be blocked and both will proceed

User1's transaction is blocked and user2 will proceed

There will be a deadlock

User2 will not be blocked and both will proceed

User1's transaction is blocked and user2 will proceed

There will be a deadlock

Page 134: SQL PDF Raviraj

Y

Y

ReadUncommitted Committed SnapShot Y Consistency

Y Prints 'I am here in one'

DELETE from TABLE1 and INSERT into TABLE2 are commited

INSERT into TABLE2 alone is committed

None of the changes to database are coMmitted

None of the listed options

Statement 1 will not execute, Statement 2 will execute.

Statement 1 will execute, Statement 2 will not execute.

Statement 1 is self join, Statement 2 is not a self join.

The results will be same but the display will be different.

Prints 'I am here in one' Prints 'I am here in two'

Prints 'I am here in two'

Prints 'I am here in one' Prints 'I am here in two'Prints 'I am here in one'

Page 135: SQL PDF Raviraj

Once 2 times zero times 3 times

Y

Y

Procedure sp_process_total_two executes before sp_process_total_one

Procedure sp_process_total_one executes before sp_process_total_two

Both procedures sp_process_total_one and sp-process_total_two get executed at same time

Procedure sp_process_two will not get executed at all

Three author profiles are retrieved from authors

One author profile is retrieved from authors

No author profiles are retrieved from authors

Gives execution error

Page 136: SQL PDF Raviraj

Five Four Y Three Six

0 1 -1 Y -2

Page 137: SQL PDF Raviraj

Two Three Y One None

Y

Y

All employees whose lastname starts with 'B' are deleted

The last employee with lastname starting with 'B' alone is deleted

The first employee with lastname starting with 'B' alone is deleted

Gives error message

1) Updates the statistics for every table in the database every night at 1 A.M 2) Write a log entry to both SQL Server log and Windows NT application log

1) Updates the statistics for every table in the database only once at 1 A.M 2) Write a log entry to both SQL Server log and Windows NT application log

1) Updates the statistics for every table in the database only once at 1 A.M

Gives error message

Page 138: SQL PDF Raviraj

Y Y

Two Three One None

Prints message 'NO ROWS FOUND'

Prints message 'ATLEAST ONE ROW FOUND'

Prints no message

Gives error message

Page 139: SQL PDF Raviraj

Y

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' ENDFROM hr.department

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' ENDFROM hr.department

SELECT deptid, name, groupname, CASE groupname WHEN groupname 'Marketing' THEN 'Room 1' WHEN groupname 'Human Resources' THEN 'Room 2' WHEN groupname 'Production' THEN 'Room 3' ELSE 'Room 4' ENDFROM hr.department

None of the listed options

Page 140: SQL PDF Raviraj

Fetch and Open both fail YFetch fails but open succeeds

Fetch succeeds but open fails

Fetch and open both succeed

Page 141: SQL PDF Raviraj

Fetch and Open both fail YFetch fails but open succeeds

Fetch succeeds but open fails

Fetch and open both succeed

Page 142: SQL PDF Raviraj

Fetch and Open both fail YFetch fails but open succeeds

Fetch succeeds but open fails

Fetch and open both succeed

Page 143: SQL PDF Raviraj

Fetch and Open both fail Y

Y

Fetch fails but open succeeds

Fetch succeeds but open fails

Fetch and open both succeed

Three author profiles are retrieved from authors

One author profile is retrieved from authors

No author profiles are retrieved from authors

Four author profiles are retrieved

Page 144: SQL PDF Raviraj

Executes with no message Y

Three author profiles are retrieved from authors

One author profile is retrieved from authors

No author profiles are retrieved from authors

Four author profiles are retrieved

Prints error message and error code

Severe database error

None of the listed options

Page 145: SQL PDF Raviraj

Y Executes with no messagePrints error message and error code

Severe database error

None of the listed options

Page 146: SQL PDF Raviraj

Y

SELECT deptid, name, groupname, CASE groupname WHEN groupname = 'Marketing' THEN 'Room 1' WHEN groupname = 'Human Resources' THEN 'Room 2' WHEN groupname = 'Production' THEN 'Room 3' ELSE 'Room 4' ENDFROM hr.department

SELECT deptid, name, groupname, CASE groupname WHEN groupname IN 'Marketing' THEN 'Room 1' WHEN groupname IN 'Human Resources' THEN 'Room 2' WHEN groupname IN 'Production' THEN 'Room 3' ELSE 'Room 4' ENDFROM hr.department

SELECT deptid, name, groupname, CASE WHEN groupname IN 'Marketing' THEN 'Room 1' WHEN groupname IN 'Human Resources' THEN 'Room 2' WHEN groupname IN 'Production' THEN 'Room 3' ELSE 'Room 4' ENDFROM hr.department

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' ENDFROM hr.department

Page 147: SQL PDF Raviraj

One book title Two book titles Y None

Y Y

Gives execution error

One row is fetched from titles

Two rows are fetched from titles

No rows are fetched from titles

Gives error message

Page 148: SQL PDF Raviraj

YNo rows are fetched from either titles or authors

One row fetched from titles and no rows from authors

One row each is fetched from titles and authors

Gives execution error message

Page 149: SQL PDF Raviraj

Y

One book title is fetched from titles and one author profile is fetched from authors

One book title is fetched from titles

One author profile is fetched from authors

Gives execution error message

Page 150: SQL PDF Raviraj

Y

One book title is fetched from titles and one author profile is fetched from authors

One book title is fetched from titles and two author profiles are fetched from authors

One book title is fetched from titles

Gives execution error message

Page 151: SQL PDF Raviraj

Five authors Three authors Y No authorsGives error message

Page 152: SQL PDF Raviraj

Y

Element Centric Attribute Centric Y Xml Centric

Prints message 'NO ROWS FOUND'

Prints message 'ATLEAST ONE ROW FOUND'

Prints no message

Gives error message

None of the listed options

Page 153: SQL PDF Raviraj

Y

Y

XSINIL Y XMLDATA XMLAUTO

BINARY BASE16 BINARYBASE32 Y

SELECT * FROM EMPLOYEEORDER BY EMPNAMEFOR XML RAW

SELECT * FROM EMPLOYEEORDER BY EMPNAMEFOR XML RAW ,XSINIL

SELECT * FROM EMPLOYEEORDER BY EMPNAMEFOR XML RAW ,ELEMENTS

SELECT * FROM EMPLOYEEORDER BY EMPNAMEFOR XML ELEMENTS

SELECT * FROM EMPLOYEEORDER BY EMPNAMEFOR XML ELEMENTS ROOT('ROOT')

SELECT * FROM EMPLOYEEORDER BY EMPNAMEFOR XML RAW('ROW!'),ELEMENTS ROOT('ROOT')

SELECT * FROM EMPLOYEEORDER BY EMPNAMEFOR XML RAW,ELEMENTS ROOT('ROW')

SELECT * FROM EMPLOYEEORDER BY EMPNAMEFOR XML RAW,ELEMENTS ROOT('ROOT')

XMLSCHEMA

BINARY BASE64

BINARY BASE128

Page 154: SQL PDF Raviraj

Y

RAW AUTO EXPLICIT Y

TRUE FALSE Y

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

Y

Statement 1 is True, and Statement 2 is False

Statement 1 is False, and Statement 2 is True

Both the Statements are True

Both the Statements are False

None of the listed options

Query() method does not support searching in XML file.

Query() method is Case Sensitive

Query() method is not supported against the XML Column

None of the listed options

Page 155: SQL PDF Raviraj

Query() Exists() Values() Nodes()

Y

Y

Y

Compliation fails as ELEMENTS is not supported with Raw method

Compliation fails as Raw method does not support joins

The query gets executed and returns a XML result set

None of the listed options

Compliation fails as AUTO method does not support joins

Compliation fails as AUTO method does not support ELEMENTS

Compliation fails as AUTO method does not support SELECT

Compliation fails as AUTO method does not support Row naming

Raw does not support ROOT and Row naming

ELEMENTS does not support ROOT and Row naming

XSINIL does not support ROOT and Row naming

XMLDATA does not support ROOT and Row naming

Page 156: SQL PDF Raviraj

Y

Y

BASE32 BASE64 Y ENCODE32 ENCODE64

SELECT * FROM SALES ORDER BY IDFOR XML RAW('CHILD'),Elements XSINIL, ROOT('ROOT')

SELECT * FROM SALES ORDER BY IDFOR XML RAW('CHILD'),Elements, ROOT('ROOT')

SELECT * FROM SALES ORDER BY IDFOR XML RAW('CHILD'), XSINIL, ROOT('ROOT')

SELECT * FROM SALES ORDER BY IDFOR XML RAW('CHILD'),Elements XSINIL

The query returns a XML result set with the xml namespace as the property of the Root node only

The query returns a xml result set in a xml schematic way

The query gets executed and returns a result set which is not a XML format

Error in the above statement

Page 157: SQL PDF Raviraj

Y

Y

Y

Y

<contentsTable contents="table" /><contentsTable contents="chair" />

<contents contentstable="table" /><contents contentstable="chair" />

<contentTable contents="table" /><contentTable contents="chair" />

<contentsTable content="table" /><contentsTable content="chair" />

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

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

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

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

Returns a xml result set with ROW tag name as PRODUCTITEM

Returns a xml result set with ROOT tag name as PRODUCTITEM

Returns a xml result set with ROW tag name as PRODUCT and ROOT tag name as PRODUCTITEM

Error in the above statement

SELECT ID, CONTENTS 'string()' FROM ITEMFOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT')

SELECT ID,CONTENTS 'innerstring()' FROM ITEMFOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT')

SELECT ID,CONTENTS 'text()' FROM ITEMFOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT')

Error in the above statement

Page 158: SQL PDF Raviraj

Y

Y

text() comment() Data() Y

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

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

<PRODUCT> <PRODUCTITEMS> <work> <worker id="1 2 0" /> </work> </PRODUCTITEMS> <PRODUCTITEMS> <work> <worker id="1 2 0" /> </work> </PRODUCTITEMS> </PRODUCT>

<PRODUCT> <PRODUCTITEMS> <?CONT table?> <worker id="1 2 0" /> </PRODUCTITEMS> <PRODUCTITEMS> <?CONT chair?> <worker id="1 2 0" /> </PRODUCTITEMS> </PRODUCT>

SELECT ID, 'Comments: ' + contents 'text()' FROM ITEMFOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT')

SELECT ID, 'Comments: ' + contents 'comment()' FROM ITEMFOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT')

SELECT ID, contents 'comment()' + ' Comments :' FROM ITEMFOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT')

SELECT ID, contents as 'comment()' FROM ITEMFOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT')

processing-instruction()

Page 159: SQL PDF Raviraj

Y

LET Y FOR WHERE ORDER BY

Y

SELECT ID, contents 'tagname/@contents' FROM ITEMFOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT')

SELECT ID, contents as 'tagname/@contents' FROM ITEMFOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT')

SELECT ID, contents 'tagname/contents' FROM ITEMFOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT')

None of the listed options

UPDATE BOOKS SET AUTHORXML.MODIFY(' INSERT <books>Sql server by Mr.SHAM</books> AFTER (subject/database/@books)[1]')

UPDATE BOOKS SET AUTHORXML.MODIFY(' INSERT <books>Sql server by Mr.SHAM</books> BEFORE (subject/database/@books)[1]')

UPDATE BOOKS SET AUTHORXML.MODIFY(' INSERT <books>Sql server by Mr.SHAM</books> NEXT (subject/database/@books)[1]')

UPDATE BOOKS SET AUTHORXML.MODIFY(' INSERT <books>Sql server by Mr.SHAM</books> INTO (subject/database/@books)[1]')

Page 160: SQL PDF Raviraj

Y

Y

Y

TRUE Y FALSE

Y

1 Y 2 Unlimited 1024

Statement 1 is True, and Statement 2 is False

Statement 1 is False, and Statement 2 is True

Both the Statements are True

Both the Statements are False

Statement 1 is True, and Statement 2 is False

Statement 1 is False, and Statement 2 is True

Both the Statements are True

Both the Statements are False

Step1 is valid, and Step2 is invalid

Step1 is valid, and Step2 is invalid

Both the Steps are valid

Both the Steps are invalid

It maintains a snapshot of the data for the duration of the transaction

It maintains statement level snapshot of the data

It takes an exclusive lock on the entire table

It isolates the database from access to other users

Page 161: SQL PDF Raviraj

TRUE Y FALSE

Lot of changes to key data Y

Y

Modifications to table or view referenced by query

Updates made to statistics used by the execution plan

All of the listed options

SELECT column1 from table1 WHERE column1 = 123;

SELECT column1 from table1 WHERE column1 <> 123;

SELECT column1 from table1 WHERE column1 = @value1

SELECT column1 from table1

Page 162: SQL PDF Raviraj

Y

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

User2's update will be overwritten by user1's update

User 1 will get an update error due to Snapshot isolation

User 2 will get an update error due to snapshot isolation

Both the updates will be successful

Page 163: SQL PDF Raviraj

2 5 7 10 Y

5 7 10 12 Y

Page 164: SQL PDF Raviraj

Y

Y

The entire transaction is rolled back

Update to 456 is rolled back but update to 123 is committed

Both the updates are comitted

Update to 123 is rolled back but update to 456 is committed

Book id's 2 and 3 are inserted successfully

Book id 2 is inserted but 3 is not inserted

Book id 3 is inserted but 2 is not inserted

Neither of the books are inserted

Page 165: SQL PDF Raviraj

Y

Y

Book id's 2 and 3 are inserted successfully

Book id 2 is inserted but 3 is not inserted

Book id 3 is inserted but 2 is not inserted

Neither of the books are inserted

The procedure creation is successful and while executing, it will return a xml file with INDIA as root node and STATE as row node

The procedure creation is successful and while executing, it will return a xml file with STATE as root node and INDIA as row node

The procedure creation is successful and while executing, it will not return a xml file due to run-time error

The procedure creation fails due to compilation error

Page 166: SQL PDF Raviraj

Y

Query will return a result set with SNO as STATE_CODE and SNAME as node

Query will return a result set with SNO as node and SNAME as STATE_CODE

Select statement is not valid

None of the listed options

Page 167: SQL PDF Raviraj

The database file names need not be unique

Local procedures are private and under control of the user who created it

Page 168: SQL PDF Raviraj

Y

The procedure is defined in a sys schema

Page 169: SQL PDF Raviraj

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

Page 170: SQL PDF Raviraj

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

Page 171: SQL PDF Raviraj

ALLOCATE contact_cursor

we can include in line 11 FETCH NEXT FROM contact_cursor13 CLOSE contact_cursor14 DEALLOCATE contact_cursor

Page 172: SQL PDF Raviraj

SECOND

first, last and none are the valid values…

Page 173: SQL PDF Raviraj

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_CONS_COLUMNS view.

Page 174: SQL PDF Raviraj
Page 175: SQL PDF Raviraj

If a database is over-normalized, i.e. the database is defined with numerous,small.interrelated tables,db performance is reduced. This is because when the db processes the data in numerous,small,interrelated tables,it has to combine the related data,which results in an increase in the database's workload. In these situations, denormalizing the database slightly can improve performance

Page 176: SQL PDF Raviraj

Sub-query in this answer will return one row value, concatenated 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

Page 177: SQL PDF Raviraj

Decreasing column length

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 values

Page 178: SQL PDF Raviraj
Page 179: SQL PDF Raviraj

It adds files to file groups.

Page 180: SQL PDF Raviraj

None of the listed optionsY

text column cannot be changed

new column can be added only in the end

Page 181: SQL PDF Raviraj
Page 182: SQL PDF Raviraj

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

Page 183: SQL PDF Raviraj

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

Page 184: SQL PDF Raviraj

cannot rebuild a dropped index, gives error

It is DDL trigger

Online indexing operation ispossible with ONLINE = ON

Page 185: SQL PDF Raviraj

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

Page 186: SQL PDF Raviraj

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

Page 187: SQL PDF Raviraj

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

Page 188: SQL PDF Raviraj

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

Page 189: SQL PDF Raviraj

Y

siince after trigger is used, the delete stmt fails before after trigger code is executed

tr_1, tr_2, tr_4, tr_3

first and last are fixed, other two in any order

Page 190: SQL PDF Raviraj

since nested trigger option is set off, the nested trigger does not fire

fixed server roles can manage linked servers by using setupadmin

Page 191: SQL PDF Raviraj

In the administration 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

Page 192: SQL PDF Raviraj

The result set will be as follows:1001 400 11004 300 21007 250 31003 200 4

The result set will be as follows:1001 400 11004 300 21007 300 21003 200 4

Page 193: SQL PDF Raviraj

The result set will be as follows:1001 400 11004 300 21007 300 21003 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

Page 194: SQL PDF Raviraj

dynamic sql in sp will allow creation of queries dynamically

None of the listed options

2 times it will be called

Page 195: SQL PDF Raviraj

sp_process is treated as an alias for table employees

Page 196: SQL PDF Raviraj

EXEC is valid and executes

only warning error if another stored procedure object is mising

With 1) parm1 = 100, parm2 = 200, parm3 = 300With 2) Gives error due to invalid parameter passing

default parameters in first case and second case only parm1 is default

since proc has recompile option, explicit recompile is not needed when invoking

Page 197: SQL PDF Raviraj

avg1 will be 100, avg2 will be 100 and avg3 will be 100

All the three are equivalent and perform same 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

Page 198: SQL PDF Raviraj

simple reference to function is enough to use it

cannot alter when the column is used in a function

Page 199: SQL PDF Raviraj

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

Page 200: SQL PDF Raviraj

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

inline table function valid type

Page 201: SQL PDF Raviraj

cannot modify function from inline to multi table

Page 202: SQL PDF Raviraj

can modify inline function stmts

execte as overrides the user name to sunil

Page 203: SQL PDF Raviraj

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

Page 204: SQL PDF Raviraj

None of the listed options

All three stmts can be used to display source code, so 3 times

None of the listed options

The statement will fail as the ITEM_ID value is larger than allowed. The CATCH block will return -101

Page 205: SQL PDF Raviraj

None of the listed options

Since the statement is successful, the statement following the CATCH block will be executed

Since OUTPUT keyword is missing, output variable will not be passed back to the variable

Page 206: SQL PDF Raviraj

Since message is not displayed for incorrect title, count is 0

Page 207: SQL PDF Raviraj

##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

Page 208: SQL PDF Raviraj

uses dynamic sql with variable list passed as parameter

multiple stored procedures can be created

Page 209: SQL PDF Raviraj

Y

None of the listed options

since default parameter is not mentioned, gives error for first parameter, and in second case since second parameter is missing gives error on parm2

None of the listed options

being a recursive procedure, will abort once nestinglevel of 32 is reached

Page 210: SQL PDF Raviraj

EXEC SelectByIdList @productIds='<Products><id>3</id><id>6</id><id>15</id></Products>'

Page 211: SQL PDF Raviraj
Page 212: SQL PDF Raviraj

No block because Update lock is compatible with Shared lock

Only one transaction can have the update lock on row 2.

Page 213: SQL PDF Raviraj

No block as the locks are on separate records

Read Committed isolation level drops the shared lock in Transaction A after the read.

Page 214: SQL PDF Raviraj

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.

Page 215: SQL PDF Raviraj
Page 216: SQL PDF Raviraj
Page 217: SQL PDF Raviraj

The results of these queries will be same, just will look different. In first statement driving column is ID, in second -MANAGER_ID.

Prints nothing

BREAK will break the loop since 1 = 1

Page 218: SQL PDF Raviraj

YNone of the listed options

End less loop

Procedure sp_process_one will not get executed at all

wait for delay delays by 2 hrs 22 seconds , time fires at 22 seconds after 2 a.m, so both fire at same time

cannot use relative, with forward_only cursor

Page 219: SQL PDF Raviraj

None of the listed options

Next and first retrive same rows

None of the listed options

no more rows, so -1 is returned which gets printed

Page 220: SQL PDF Raviraj

Gives error message

both cursor and cursor variable used interchangeably

Cannot update/delete with fast_forward option

while loop keeps it running, and waitfor time will make sure at 1 am the update is done

Page 221: SQL PDF Raviraj

Y

since cursor check does not do anything, message dispalyed for fetch status check

Gives error message

Since cursor variable is not set to cursor , error occurs

Page 222: SQL PDF Raviraj
Page 223: SQL PDF Raviraj

open succeeds since not fully dealocated

Page 224: SQL PDF Raviraj

since fully deallocated at the end, cannot open after that

Page 225: SQL PDF Raviraj

since both references are deallocated, cannot fetch or open

Page 226: SQL PDF Raviraj

since not deallocated, open works

Gives error message

fast forward allows next

Page 227: SQL PDF Raviraj

YGives error message

with fast forward next only is allowed

since not exists is satisfied,just returns no message

Page 228: SQL PDF Raviraj

since temp proc is invoked, it gives divide by 0 error and error message is printed

Page 229: SQL PDF Raviraj

None of the listed options

regular case is converted to boolean case as in 4

Page 230: SQL PDF Raviraj

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

Page 231: SQL PDF Raviraj

local cursors can be with same name, hence valid and one row fetched from authors and titles each

Page 232: SQL PDF Raviraj

since cursor is open, fetch of c2 from sp_one should work

Page 233: SQL PDF Raviraj

since cursor is not deallocated, it is available even after sp_one finishes execution and hence c2 is available for fetch

Page 234: SQL PDF Raviraj
Page 235: SQL PDF Raviraj

Since cursor rows is checked and returned, no message is printed

Page 236: SQL PDF Raviraj

BINARY BASE64 is the only available encoding technique

Page 237: SQL PDF Raviraj

Pro-long part is an optional one when used along with 'WITH' Statement.

Page 238: SQL PDF Raviraj

YNone of the listed options

Page 239: SQL PDF Raviraj
Page 240: SQL PDF Raviraj

XSINIL will not support if no ELEMENTS is used

Page 241: SQL PDF Raviraj
Page 242: SQL PDF Raviraj
Page 243: SQL PDF Raviraj

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

Page 244: SQL PDF Raviraj

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.

Page 245: SQL PDF Raviraj
Page 246: SQL PDF Raviraj
Page 247: SQL PDF Raviraj
Page 248: SQL PDF Raviraj

Compilation fails because passing a variable is not possible in ROOT clause

Page 249: SQL PDF Raviraj

Value function is not supported in dynamic table