You are on page 1of 99

1. It is mandatory to define at least one secondary data file for a database. 2.

3.

State True or False. Ans. False 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? Ans Statement 1 is true, 2 is false Which of the following are correct with respect to Filegroups?(Choose 2) Ans. Filegroups apply only to data files and not log files,

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

4. When creating a database, which of the following should be considered when


selecting the location of the database files?(Choose 3) Ans. 1.Database files should have sufficient space for growth, 2.Choose a common location or directory to keep the database files to keep things organized,3. The path specified for locating the database files should exist before creating a database

5. 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? Ans. Both Statements 1 and 2 are true

6. Which of the following are features of a local temporay stored procedure?(Choose


2) Ans. It is automatically deleted when the connection is closed, It can be executed only by the connection that created it

7. Which of the following are correct for temporary tables used in Stored procedures?
(Choose 2) Ans. 1.Local temporary tables created in a stored procedure are automatically dropped when the stored procedure exits.,2. Global temporary tables are not available if the user session in which they were created disconnects from the SQL Server.

8. 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? Ans. Statement 2 and 3 are true, 1 is false

9. Which of the following attributes characterise System Stored Procedures?(Choose


3)

Ans. 1.The stored procedure name begins with sp_., 2.The stored procedure resides in a Resource database The procedure is defined in a sys schema

10.

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? Ans. Statement 1 is false, 2 is true

11. Which of the following cannot be passed as input parameter values to a Stored procedure?(Choose 2) Ans. Function, Expression 12.Consider the following statement: Select title_id, price, type from titles where price > dbo.AverageBookPrice('comp_science') Ans. Scalar function What kind of a User Defined Function is used in the above statement? 12. 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. Ans. Both Statements 1 and 2 are true Which of the following is applicable for the above? 13. You are currently working with an application with lage processor-intensive calculations.Which of the following stored procedure would you prefer? Ans. A CLR-integrated stored procedure 14. Which of the following error type can be handled within a TRY..CATCH construct of handling errors in stored procedures? Ans. Severity 20 or higher errors that do not result in closing of a connection 15. Which of the following type of statement are allowed to be included in a User Defined Function? Ans.1. Declare statements to define variables and cursors that are local to the function,2. EXECUTE statements that call an extended stored procedure, all the above

16. 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?ans. Multi-statement table valued function 17. Which of the following is not an advantage of Stored Procedure?ans Automatic Execution 18. Which of the following stored procedures are ideal candidates to be re-written as User Defined Functions?(Choose 2) ans. 1.The stored procedure does not

FETCH SECOND

perform update operations on tables, except against table variables, 2.The stored procedure returns no more than a single result set 19. 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) ans.1. Drop the procedure using DROP and re-create a new one using CREATE command,2. Modify the procedure using ALTER command 21. Consider the following scenario: The creator of a stored procedure also owns the tables that it references. Statement 1: An user can execute the stored procedure but cannot access the referenced table unless the creator grants access to the table Statement 2: An user can execute the stored procedure and inherits the rights on the referenced table from the owner within the context of the stored procedure Which of the following is applicable for the above? A. Statement 1 is true, 2 is false B. Statement 1 is false, 2 is true C. Both Statements 1 and 2 are true D. Both Statements 1 and 2 are false 22. Which of the following option defines a cursor that makes a temporary copy of the data to be used by the cursor? A. STATIC B. DYNAMIC C. KEYSET D. FAST_FORWARD 23. Which of the following options is used to retrieve the second record from a table? A. FETCH SECOND B. FETCH ABSOLUTE 2 C. FETCH RELATIVE 2 D. None of the listed options 24. 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 minimize locking contention for updates and deletions of a large number of rows in a table.

Which of the following is applicable for above? A. Statement 1 is true, 2 is false B. Statement 1 is false, 2 is true C. Both Statements 1 and 2 are true D. Both Statements 1 and 2 are false 25. 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? A. Statement 1 is true, 2 is false B. Statement 1 is false, 2 is true C. Both Statements 1 and 2 are true D. Both Statements 1 and 2 are false 26. 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? A. Statement 1 is true, 2 is false B. Statement 1 is false, 2 is true C. Both Statements 1 and 2 are true D. Both Statements 1 and 2 are false 27. Below is a code snippet for cursor: 01 02 03 04 05 06 07 USE AdventureWorks GO DECLARE contact_cursor CURSOR FOR SELECT LastName FROM Person.Contact WHERE LastName LIKE 'B%' ORDER BY LastName OPEN contact_cursor

08 09 10 11 12 13 14

FETCH NEXT FROM contact_cursor WHILE @@FETCH_STATUS = 0 BEGIN ---- Missing Line END ---- Missing Line ---- Missing Line

Which of the following lines of code can be correctly fitted into the missing lines?(Choose 3) A. FETCH NEXT FROM contact_cursor B. OPEN contact_cursor C. DEALLOCATE contact_cursor D. CLOSE contact_cursor E. ALLOCATE contact_cursor 28. Which of the following cursor creation option specifies that all fetch options (FIRST,LAST,PRIOR,NEXT,RELATIVE,ABSOLUTE) are available? A. Local B. Scroll C. Global D. Scroll_locks 29. The INSTEAD of trigger can be applied to a view and triggered based on the modifications to the view. State True or False. A. TRUE B. FALSE 30. Which of the following is limitation of INSTEAD of trigger? A. INSTEAD trigger does not support recursion B. Only one INSTEAD of trigger can be defined for each action on a given table C. A table cannot have an INSTEAD of trigger and FOREIGN KEY constraint with CASCADE defined for the same action D. All of the listed options 31. 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)

A. FIRST B. NONE C. ANY D. LAST E. SECOND 32. For which of the following it is ideal to define non-clustered indexes? A. Queries that do not return large result sets B. Columns that are frequently used in the WHERE clause that return exact matches C. Coumns that have many distinct values D. All of the listed options 33. 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) A. Using Stored procedures B. Defining indexes C. Defining foreign key constraints D. Defining views 34. Which of the following is a perfect match with reference to an Index? A. Smallest unit of data storage B. Automatically created at the time of creating a table C. Allows an application program to find specific data without scanning through the entire table D. contains information about modifications carried out in the database 35. Where are SQL Server user names and Passwords stored in sql server? A. Under msdb database in sysxlogins tables B. Under tempdb database in sysxlogins tables C. Under Master database in sysxlogins tables D. None of the listed options

36. A table can not have more than one clustered index. State True or False A. TRUE. B. FALSE. 37. 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 behavior which is different from the traditional SQL server data types. Which of the following feature we can use to address the above requirement? A. View B. temp table C. User Defined Type D. Extension 38. 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? A. msdb B. model C.master D.tempdb 39. Which of the following are correct for indexed views?(Choose 2) A. An indexed view is any view that has a clustered index defined on it B. The indexed view is a logical entity and is not materialized in the database C. You can create only one index on a view D. Indexed views aid in optmizing performance 40. 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? A. GRANT select ON dept TO ALL_ USERS B. GRANT QUERY ON dept TO ALL_USERS C. GRANT select ON dept TO PUBLIC;

D. None of the listed options

41. When of the following subquery takes parameters from its parent query? a. Nested subquery b. Correlated subquery c. Plain Subquery d. Join Subquery 42. Which of the following is NOT used to combine data from multiple tables? a. Union b. Subquery c. Join d. Role 43. Which of the following helps us to create and populate a new table with the data of an existing table? a. SELECT INTO b. UNION c. SUBQUERY d. JOIN 44. A set of statements is to be executed 10 times. Which of the following constructs can we use for this task? a. b. c. d. IF..ELSE WHILE CASE None of the listed options

45. Which of the following type of integrity is correct for the statement 'Ensures that the values in a column are within the Specified Range'? a. Integrity b. Domain Integrity c. User Defined Integrity d. Entity Integrity 46. Which of the following type of integrity maintains the relationship between tables in a database? a. b. c. d. Referential Integrity Domain Integrity User Defined Integrity Entity Integrity

47. Which of the following type of integrity ensures each record in a table is Unique? a. Data Integrity

b. Domain Integrity c. User Defined Integrity d. Entity Integrity 48. 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? Create a view on the four tables. Create an index on the view a. Denormalize the database design if possible b. Further normalize the table c. Define Referential Integrity constraints so that data can be referenced faster 49. Examine the structure of the EMPLOYEES and NEW_EMPLOYEES tables

employees employee_id INT Primary Key first_name VARCHAR (25) last_name VARCHAR(25) hire_date DATE DATETIME

new_employees employee_id INT Primary Key name VARCHAR(50)

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

a. UPDATE new_employees SET name = (Select last_name || first_name FROM employees


Where employee_id =180)---------

-Y

b. 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) c. None of the listed options

d. 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 50. Which of the following is a valid statement about sub queries? a. A subquery must be enclosed in parenthesis b. A subquery must be put in the right hand side of the comparison operator c. A subquery cannot contain a ORDER-BY clause

d. A query should not contain more than one sub-query----

51. 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) a. b. c. d. e. f. Insert Changing Column Name Increasing column length Modify datatype 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

52. 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? a. Creates four partitions 1) for data before 1993 2) for data of 1993 3) for data of 1994 4) for data of 1995 or later b. Creates three partitions

1) for data of 1993 2) for data of 1994 3) for data of 1995 or later c. Creates four partitions 1) for data before 1993 2) for data of 1993 3) for data of 1994 4) for data of 1995 d. Creates three partitions 1) for data of 1993 or prior to 1993 2) for data of 1994 3) for data of 1995 or later

53. Consider the following statements: A view is created as follows: CREATE VIEW EmployeeView as SELECT empid, birthdate, gender, hiredate from Hr.Employees where hiredate > '2/1/07' The following select statement uses the above view: SELECT * from EmployeeView where birthdate > '3/1/65' What does the above SELECT statement retrieve? a. It retrieves information of employees born after March 1, 1965 and who have been hired after february 1, 2007 b. It retrieves information of employees born after March 1, 1965 c. It retrieves information of employees who have been hired after february 1, 2007 d. It retrieves information of employees born on or after March 1, 1965 and who have been hired on or after after february 1, 2007

54. 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_date FROM sys.views;

What does IsIndexable return in the above statement?

a. 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 b. IsIndexable is a property that returns 1 if an index can be created on the view, and 0 if it is not indexable. c. IsIndexable is a property that returns 0 if an index can be created on the view, and 1 if it is not indexable. d. IsIndexable is a property that returns 0 if an index can be created on the view, and 1 if it is not indexable. 55. 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? a. b. c. d. SCHEMABINDING clause FOR CREATION OF INDEX clause UNIQUE clause in the CREATE SCHEMA line Database qualifier for each table

56. 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? a. b. c. d. Adds files with new names Adds files to folders Adds files to filegroups Adds files to database

57. 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. a. Select * from prod.product_details where unit_of_measure = 'KG' OPTION(NOEXPAND VIEWS)

b. Select * from prod.product_details where unit_of_measure = 'KG' OPTION(EXPAND VIEWS)

c. Select * from prod.product_details where unit_of_measure = 'KG'

d. Select * from prod.product_details where unit_of_measure = 'KG' OPTION(EXPAND INDEXES)

58. Consider the following statements: ALTER DATABASE Employee MODIFY FILE (Name = Employee_log, FILENAME = 'C:\Employee_log.ldf') What does the above statement achieve?

a. b. c. d.

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 None of the listed options

59. 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)

a. b. c. d.

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

60. Consider the following statements: CREATE PARTITION SCHEME CustPS1 AS 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? a. Creates partitioned view CustPS1 on table customers_p1 b. Creates Customers_p1 table in file group custPS1 c. Creates Customers_p1 table in partition scheme custPS1 and column order_dt is used for partitioning d. None of the listed options 61.Consider the following statements: CREATE PARTITION SCHEME CustPS1 AS 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? A Creates table Table1 in filegroup userdata_FG and creates a clustered index in filegroup userdata_FG B Creates table Table1 in filegroup userdata_FG and creates a clustered index in default filegroup C Creates table Table1 in filegroup userdata_FG and creates a clustered index in filegroup userindex_FG D None of the listed options 62 Assume there is a table emp defined with columns as emp_id smallint emp_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? A ALTER TABLE emp ALTER COLUMN emp_address VARCHAR(40) NULL B ALTER TABLE emp ALTER COLUMN emp_address VARCHAR(40) NOT NULL

C ALTER COLUMN emp_address of TABLE emp VARCHAR(40) NULL D ALTER COLUMN emp_address of TABLE emp VARCHAR(40) NOT NULL E None of the listed options text column cannot be changed 63 Assume there is a table emp defined with columns as emp_id smallint emp_name char emp_address char Which of the following command can be issued to change the datatype of column emp_address from char to nchar? A ALTER TABLE emp ALTER COLUMN emp_address nchar NULL B ALTER COLUMN emp_address of TABLE emp nchar NULL C ALTER COLUMN emp.emp_address nchar NULL D None of the listed options 64 Assume there is a table emp defined with columns as emp_id smallint emp_name char emp_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? A ALTER TABLE emp ADD emp_gender char NOT NULL B ALTER TABLE ADD emp.emp_gender char NOT NULL C ALTER TABLE emp ADD emp.emp_gender char NOT NULL AFTER emp_name D None of the listed options new column can be added only in the end 65 Assume there is a table emp defined with columns as emp_id smallint emp_name char emp_address text

In case you want to add a new column emp_gender to the above table, which of the following can be used? A ALTER TABLE ADD emp.emp_gender char NOT NULL B ALTER TABLE emp ADD emp_gender char NOT NULL C ALTER TABLE emp ADD AT END emp_gender char NOT NULL D None of the listed options 66 Consider the following statement: CREATE VIEW sales.sales_sum_vu as SELECT datepart(yy, orderdate) as 'order_year', datepart(mm, orderdate) as 'order_month', sum(totaldue) FROM sales.sales_order GROUP BY datepart(yy, orderdate), datepart(mm, orderdate) What is the outcome of the above create statement? A Creates a simple view successfully. B Create fails because derived columns are not allowed in SELECT C Create fails because derived columns in SELECT should have a name or alias associated with it DCreates an indexed view successfully. 67 Consider the following statement: CREATE VIEW sales.sales_sum_vu as SELECT datepart(yy, orderdate) as 'OrderYear', datepart(mm, orderdate) as 'OrderMonth', sum(totaldue) as 'TotalDue' FROM sales.sales_order GROUP BY datepart(yy, orderdate), datepart(mm, orderdate) ORDER BY OrderYear, OrderMonth What is the outcome of the above create statement? A Creates a simple view successfully.

B Create fails because derived columns are not allowed in SELECT C Create fails because ORDER BY clause is not allowed in this statement D Creates an indexed view successfully. 68Consider the following statements: CREATE VIEW sales.sales_sum_vu as SELECT datepart(yy, orderdate) as 'OrderYear', datepart(mm, orderdate) as 'OrderMonth', sum(totaldue) as 'TotalDue' FROM sales.sales_order GROUP BY datepart(yy, orderdate), datepart(mm, orderdate)

SELECT top 5 * FROM sales.sales_sum_vu WHERE OrderYear >=2007 ORDER BY OrderYear, OrderMonth Which of the following is applicable for above statements? A Creates a simple view, and retrieves maximum of five records based on the given criteria B Create fails because the CREATE statement does not have ORDER BY clause C Creates a simple view and retrieves minimum of five records based on the criteria D Create fails because GROUP BY clause is not allowed in CREATE statement 69 Consider the following statements: CREATE VIEW hr.male_emp_vu AS SELECT empid, empname, empgender FROM hr.employees WHERE empgender = 'M' WITH CHECK OPTION

UPDATE hr.male_emp_vu SET empgender = 'F' WHERE empid = 1001 What is the outcome of the satements as above? A The CREATE statement fails because CHECK OPTION is invalid for create view B The CREATE and the UPDATE statements go through successfully C The CREATE statement goes through but UPDATE statement fails D None of the listed options With check option we cannot update the column that would change the view retrieval contents

70 Consider the following statements:

CREATE VIEW credit_card_vu AS SELECT creditcardid, cardtype, cardno, expmonth, expyear FROM sales.creditcard UPDATE credit_card_vu set expyear = expyear + 1 WHERE expyear <= 2004 What is the outcome of the above statements? A The CREATE statement fails B The CREATE and the UPDATE statements go through successfully C The CREATE statement goes through but UPDATE statement fails D None of the listed options 71 Consider the following SELECT statement: SELECT territoryid, sum(totaldue)

FROM sales.salesorder GROUP BY territoryid ORDER 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? A CREATE VIEW sales_vu AS SELECT territoryid, sum(totaldue) 'Totalsales' FROM sales.salesorder GROUP BY territoryid ORDER BY territoryid B CREATE VIEW sales_vu AS SELECT territoryid, sum(totaldue) 'Totalsales' FROM sales.salesorder ORDER BY territoryid C CREATE VIEW sales_vu AS SELECT territoryid, sum(totaldue) 'Totalsales' FROM sales.salesorder GROUP BY territoryid D None of the listed options view does not support order by, so the select stmt cannot be exactly created as a view 72 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? A two clustered indexes idx1 and idx2 will be created on emp table B Only one clustered index idx1 will be created on emp table C Only one clustered index idx2 will be created on emp table

D No index will be created on emp table only one clustered index is allowed, the second one will fail 73 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? A Creates non-clustered indexes idx1 on empname and idx2 on empdob, both in descending order B Creates clustered index idx1 on empname and non-clustered index idx2 on empdob, both in ascending order C Creates non-clustered indexes idx1 on empname and idx2 on empdob, both in ascending order D Creates clustered index idx1 on empname and non-clustered index idx2 on empdob, both in descending order default is ASC for first one 74 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? A Create a unique clustered index on emailed B Create a unique non-clustered index on emailed C Create a non unique clustered index on emailed D This requirement cannot be met by creating indexes unique clustered cannot be created because already one clustered indx exists 75 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? A It concatenates empaddress to empname to form the index B It creates index values for empname only if address is present(not null) C It includes empaddress in the leaf level pages of the index D None of the listed options keeps address data in index for immediate retrieval 76 Assume there is an existing table 'emp' with columns as empid, empname, empdob, empaddress In addition, a non-clustered index (idx1) exists on empdob column. The following statements are issued : ALTER INDEX idx1 ON emp DISABLE DROP INDEX emp.idx1 What is the final outcome of issuing the above statements? A The index idx1 is completely removed B The index idx1 is temporarily disabled C The index idx1 is permanently disabled D The statements end with execution error drop finally removes the index 77Assume there is an existing table 'emp' with columns as empid, empname, empdob, empaddress In addition, a non-clustered index (idx1) exists on empdob column. The following statements are issued : ALTER INDEX idx1 ON emp DISABLE DROP INDEX emp.idx1 ALTER INDEX idx1 ON emp REBUILD What is the final outcome of issuing the above statements? A The index idx1 gets recreated B The index idx1 is temporarily disabled

C The index idx1 is permanently disabled D The statements end with execution error cannot rebuild a dropped index, gives error 78Below is a trigger defined : 01 USE master 02 GO 03 CREATE TRIGGER srv_trg_RestrictNewLogins 04 ON ALL SERVER 05 FOR CREATE_LOGIN 06 AS 07 PRINT 'No login creations without DBA involvement.' 08 ROLLBACK 09 GO What does the above trigger achieve

A It is a AFTER DML trigger that restricts addition of new users except with DBA privileges B It is an INSTEAD OF trigger that restricts addition of new users except with DBA privileges C It is a DDL trigger that restricts creation of new user logins into a server D None of the listed options It is DDL trigger 79 Assume there is an existing table 'emp' with columns as empid, empname, empdob, empaddress In addition, a non-clustered index (idx1) exists on empdob column. Transaction processing and updates happen 24*7 on the 'emp' table. Index idx1 has become fragmented and needs to be rebuilt. Which of the following will achieve the above? A Use ALTER command and disable the index using DISABLE clause and rebuild using REBUILD clause B Use ALTER command and rebuild the index using REBUILD clause

C Use ALTER command and rebuild using REBUILD with ONLINE = ON clause D Rebuild is not possible when the table is updated 24*7 Online indexing operation ispossible with ONLINE = ON 80 The following trigger is created an a table called 'authors' that has columns au_id, au_name,city CREATE TRIGGER tr_au_upd ON authors FOR INSERT, UPDATE AS IF UPDATE(city) BEGIN ROLLBACK TRAN END GO The following statement is executed on the authors table: UPDATE authors SET city = 'MUMBAI' WHERE au_id = '1001'

What will be the outcome of the above statement? A The city for au_id = 1001 is changed to MUMBAI in authors table B The city for au_id = 1001 is set to NULL in authors table C The city for au_id = 1001 is not changed in the authors table D None of the listed options UPDATE function restricts changes to city and trigger rolls back update 81) The following trigger is created an a table called 'authors' that has columns au_id, au_name,city CREATE TRIGGER tr_au_upd ON authors FOR INSERT, UPDATE AS IF UPDATE(city) BEGIN ROLLBACK TRAN END GO

The following statement is executed on the authors table: INSERT authors(au_id, au_name,city) VALUES (1001, 'PRAKASH', 'MUMBAI'') What will be the outcome of the above statement? A A new row for au_id = 1001 is inserted with name = PRAKASH and city = MUMBAI B No row is added for au_id = 1001 C A new row for au_id = 1001 is inserted with name = PRAKASH and city = NULL D None of the listed options 82) The following trigger is created an a table called 'authors' that has columns au_id, au_name,city CREATE TRIGGER tr_au_upd ON authors FOR INSERT, UPDATE AS IF UPDATE(city) BEGIN ROLLBACK TRAN END GO The following statement is executed on the authors table: INSERT authors(au_id, au_name) VALUES (1001, 'PRAKASH') What will be the outcome of the above statement? A A new row for au_id = 1001 is inserted with name = PRAKASH and city = NULL B No row is added for au_id = 1001 C A new row for au_id = 1001 is inserted with name = PRAKASH and city = blank D None of the listed options 83) The following trigger is created an a table called 'authors' that has columns au_id, au_name,city CREATE TRIGGER tr_au_upd ON authors FOR UPDATE AS IF UPDATE(city) BEGIN ROLLBACK TRAN END GO The following statement is executed on the authors table: INSERT authors(au_id, au_name) VALUES (1001, 'PRAKASH') What will be the outcome of the above statement?

A A new row for au_id = 1001 is inserted with name = PRAKASH and city = NULL B No row is added for au_id = 1001 C A new row for au_id = 1001 is inserted with name = PRAKASH and city = blank D None of the listed options 84) The following trigger is created an a table called 'authors' that has columns au_id, au_name,city CREATE TRIGGER tr_au_upd ON authors INSTEAD OF UPDATE AS PRINT 'Trigger output row updated' GO The following statements are executed on the authors table: INSERT authors(au_id, au_name) VALUES (1001, 'Rajeev') UPDATE authors SET au_name = 'Raghav' WHERE au_id = 1001 GO SELECT au_id, au_name WHERE au_id =1001 GO What will be the outcome of the above SELECT statement? A Select shows au_id = 1001 and au_name = 'Rajeev' B Select shows au_id = 1001 and au_name = 'Raghav' C Select shows au_id = 1001 and au_name as NULL D None of the listed options 85) The following trigger is created an a table called 'authors' that has columns au_id, au_name,city CREATE TRIGGER tr_au_upd ON authors INSTEAD OF UPDATE AS IF @@ROWCOUNT = 0 RETURN UPDATE authors SET au_name = 'Raman' WHERE au_id = 1001 GO The following statements are executed on the authors table: INSERT authors(au_id, au_name) VALUES (1001, 'Rajeev') UPDATE authors SET au_name = 'Raghav' WHERE au_id = 1001 GO SELECT au_id, au_name WHERE au_id =1001 GO What will be the outcome of the above SELECT statement? A Select shows au_id = 1001 and au_name = 'Rajeev'

B Select shows au_id = 1001 and au_name = 'Raghav' C Select shows au_id = 1001 and au_name as NULL D Select shows au_id = 1001 and au_name = 'Raman' 86) The following trigger is scoped at database level: CREATE TRIGGER tr_table_audit ON DATABASE FOR CREATE_TABLE, ALTER_TABLE, DROP_TABLE AS ROLLBACK GO The following statement is isused on table 'titles' in the database ALTER TABLE titles ADD new_col INT NULL ALTER TABLE titles DROP COLUMN new_col What is the final outcome of issuing the ALTER statements? A The new column new_col is created and dropped on table titles B The new column new_col is created on table titles but drop fails C Creation of new column new_col on table titles itself fails D None of the listed options 87) The following trigger is created CREATE TRIGGER tr_index_audit ON DATABASE FOR CREATE_INDEX, ALTER_TABLE, DROP_INDEX AS DECLARE @EventData XML SET @EventData = EVENTDATA() SELECT @EventData.Query ('' data(/EVENT_INSTANCE/PostTime )'' ) GO The following statement is issued on table 'titles' in the database(titles table has columns titleid, titlename) CREATE CLUSTERED INDEX idx1 on titles(titlename) What is the final outcome of issuing the CREATE statement? A The clustered index idx1 fails to create B The clustered index idx1 is created on titles table colum titlename and the event-specific information appears in the results pane C The clustered index idx1 is created on titles table colum titlename without any notification D None of the listed options 88) 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? A Directly use the UPDATE statement on the view to update columns from both the base tables B There is no solution to update the columns from both tables using the view C Create an INSTEAD of UPDATE Trigger on the view and update tables as part of trigger code D Create an AFTER Trigger on the view and update tables as part of trigger code 89) Consider the following scenario: Table 'dept' holds information about departments like deptid, deptname, location deptid is the primary key Table 'emp' holds information about employees like empid, name, deptid, dateofbirth deptid is the foreign key referencing the primary key deptid of table dept. In case a department is closed, the department row needs to be deleted from 'dept' table. Since foreign key constraint exists, the department row cannot be deleted if there are any employees in that department. To overcome the above, an AFTER TRIGGER was created on the 'dept' table with code to delete the individual employee rows based on the deptid. Which of the following is the final outcome of issuing a DELETE statement for a deptid in the 'dept' table? A The employee rows in table empgets deleted and the department row in dept table is then deleted B The employee rows in emp table alone get deleted C The department row in dept table alone gets deleted D The delete on dept table fails due to foreign key constraint and no further deletions take place on dept or emp table 90) 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) A tr_1 , tr_4, tr_2, tr_3 B tr_1, tr_5, tr_4, tr_3

C tr_4, tr_1, tr_2, tr_3 D tr_1, tr_2, tr_5, tr_3 91) 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? A Both the employees and jobs tables are updated B Only jobs table gets updated C Only employees table gets updated D Both the jobs and employees tables are not updated 92) We identify a transaction __________. A by its name B by its parameters C by its performance D by its ACID property 93) Which of the following applies to SQL Server transaction? A It must be isolated B It must be durable C It must be sealed D None of the listed options 94) Which of the following denotes Transaction Control command in SQL? A ROLLBACK B COMMIT C SAVEPOINT D All of the listed options 95) Which of the following command is used to undo the current transaction in SQL Server? A COMMIT

B ROLLBACK C ALTER D SAVEPOINT 96) Which of the following is the Highest isolation level in SQL Server 2005? A Read uncommitted B Read Committed C Repeatable Read D Serializable 97) Which of the following we can use to identify the number of active transactions for current connection? A @@TRANCOUNT B @@TRANS C @@TRASACTIONCOUNT D @@TRANSACTIONS 98) Which of the following is used to locate specific content and elements within an XML document? A XPATH B XML C XTEMPLETS D XSD 99) XML columns can only have one primary XML index defined. How many maximum secondary indices can be defined? A2 B4 C3 D7 100) Which of the following is NOT a valid Replication type? A Transactional Replications B Snapshot Replications

C Traditional Replications D Merge Replications 101. Which of the following command is used to view the XML indexes used in the database? 1. sys.XML_indexes 2. sys.XML_index 3. sys.XML_indexes_ALL 4. sys.XML_indexes_catalog

102. Which of the following fixed server roles can manage linked servers? 1. processadmin 2. setupadmin 3. securityadmin 4. serveradmin

103. You need to perform these tasks: 01 Create and assign a MANAGER role to Blake and Clark 02 Grant CREATE TABLE and CREATE VIEW privileges to Blake and Clark Which of the following set of SQL statements achieves the desired results? 1. CREATE ROLE manager GRANT create table, create view TO manager; GRANT manager TO BLACK, CLARK; 2. CREATE ROLE manager GRANT create table, create voew TO manager; GRANT manager ROLE TO BLACK, CLARK; 3. GRANT manager ROLE TO BLACK, CLARK; GRANT create table, create voew TO BLACK CLARK; 4. None of the listed options

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

1. GENERATE SEQUENCE SE START WITH 30 ADD BY 20 2. CREATE SEQUENCE SE START WITH 30 ADD BY 20 3. CREATE SEQUENCE SE START WITH 30 INCREMENT BY 20 4. GENERATE SEQUENCE SE INITIATE WITH 30 INCREMENT BY 20

105. There is a project allocation table which has the following structure: EmpNum int, ProjNum int, AllocDate DateTime, ReleaseDate DateTime EmpNum 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. 1. EmpNum column or ProjNum column can not have duplicate values 2. EmpNum and ProjNum columns can not be nullable 3. More than one column is not allowed for a primary key constraint 4. It is better to define two primary key constraints with EmpNum and ProjNum separately

106. 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 option What happens when a department is deleted in the DEPARTMENT table? 1. All records in EMPLOYEE table belonging to that department are deleted 2. The Dept_id column in EMPLOYEE table belonging to that department is updated to spaces

3. The Dept_id in EMPLOYEE table belonging to that department is set to NULL 4. Update fails if there are any records in EMPLOYEE table for that Dept_id

107. 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 What happens when a department, with no associated EMPLOYEE records, is deleted in the DEPARTMENT table? 1. The DEPARTMENT record is deleted but there is no update done on EMPLOYEE table

2. No update occurs and no error is given 3. An error is returned as data integrity is violated 4.It leads to unpredictable results 108. 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? 1. The DEPARTMENT record is deleted but there is no update done on EMPLOYEE table 2. The DEPARTMENT record is deleted and the Dept_id column in EMPLOYEE tabel is set to null values 3. The DEPARTMENT record is deleted and the Dept_id column in EMPLOYEE tabel is set to spaces 4. An error is returned as data integrity is violated 109. Consider the following table (ORDERS) OrderNum 3001 3003 3002 3005 3004 Amount ODATE CustNum 250 03-oct-94 1007 200 03-oct-94 1001 300 03-oct-94 1004 200 04-oct-94 1001 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_Number from ORDERS group by CustNum order by sum(Amount) desc 1.1 2.1 3.3 4.4 110. Consider the following table (ORDERS) OrderNum 3001 3003 3002 3005 Amount ODATE CustNum 300 03-oct-94 1007 200 03-oct-94 1001 300 03-oct-94 1004 200 04-oct-94 1001

3004

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 Rank from ORDERS group by CustNum order by sum(Amount) desc 1.1 2.2 3.3 4.4 111. Consider the following table (ORDERS) OrderNum 3001 3003 3002 3005 3004 Amount ODATE CustNum 300 03-oct-94 1007 200 03-oct-94 1001 300 03-oct-94 1004 200 04-oct-94 1001 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_Rank from ORDERS group by CustNum order by sum(Amount) desc 1.1 2.2 3.3 4.4 112. Consider a table 'employees' and a stored procedure 'sp_process' The following statements are executed: sp_process SELECT * from employees What is the outcome of above execution? 1. The SELECT statement does not execute but stored procedure sp_process executes 2. The SELECT statement executes but stored procedure sp_process does not execute

3. Both SELECT and stored procedure sp_process fail to execute 4. Both SELECT and stored procedure sp_process execute successfully

113. Consider the following statements: CREATE PROC myproc @parm1 int, @parm2 int, @parm3 int AS ----processing done here RETURN The above PROC is executed twice as below: 1) EXEC myproc @parm1 = 4, 5, 6 2) EXEC myproc 4, @parm2 = 5, @parm3 = 6 What is the outcome of executing as above? 1. With 1) The PROC runs successfully using the parameter values supplied With 2) The PROC runs successfully using the parameter values supplied 2. With 1) The PROC give error as the parameters are not supplied properly With 2) The PROC runs successfully using the parameter values supplied 3. With 1) The PROC runs successfully using the parameter values supplied With 2) The PROC gives error as the parameters are not supplied properly 4. With 1) The PROC gives error as the parameters are not supplied properly With 2) The PROC gives error as the parameters are not supplied properly

114. 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? 1. ALTER DATABASE <database> SET TRUSTWORTHY ON go sp_configure 'clr enabled', 1 go reconfigure go 2. ALTER DATABASE <database> SET TRUSTWORTHY ON go sp_configure 'clr enabled', 1 go

3. ALTER DATABASE <database> SET TRUSTWORTHY ON go sp_configure 'clr' go reconfigure go 4. ALTER DATABASE <database> SET TRUSTWORTHY ON sp_configure 'clr' reconfigures

115. 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? 1. Use Dynamic SQL in stored procedures 2. Use Nested stored procedures 3. Use extended stored procedures 4. Drop the stored procedures that are not in use

116. Consider the following stored procedures: CREATE proc main_proc AS exec sub_proc1 exec sub_proc2 return go CREATE proc sub_proc1 AS exec sub_proc2 go CREATE proc sub_proc2 AS return How many times will the proc sub_proc2 get executed upon invoking EXEC main_proc?

1. 2 times 2. 16 times 3. 32 times 4. 31 times 5. None of the listed options

117. 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; END ELSE 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 -----? 1. IF @@ERROR <> 0 2. IF @@ERROR = 0 3. IF ERROR = 0 4. IF ERROR <> 0

118. 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? 1. Creates a new proc get_au_name and deletes the proc create_other_proc 2. Gives execution error 3. Creates a new proc get_au_name 4. None of the listed options

119. Consider a table 'employees' and a stored procedure 'sp_process' The following statements are executed: SELECT * from employees sp_process What is the outcome of the above execution? 1. The SELECT statement does not execute but stored procedure sp_process executes 2. The SELECT statement executes but stored procedure sp_process does not execute 3. Both SELECT and stored procedure sp_process fail to execute 4. Both SELECT and stored procedure sp_process execute successfully 120. Consider a table 'employees' and a stored procedure 'sp_process' The following statements are executed: SELECT * from employees EXEC sp_process What is the outcome of the above execution? 1. The SELECT statement does not execute but stored procedure sp_process executes 2. The SELECT statement executes but stored procedure sp_process does not execute 3. Both SELECT and stored procedure sp_process fail to execute 4. Both SELECT and stored procedure sp_process execute successfully

121. Consider the following stored procedure creation:

CREATE proc sp_create_staff AS EXEC sp_use_jobs It so happens that the user missed creating the stored procedure sp_use_jobs in the database. What will be the outcome of the create procedure sp_create_staff as above? a. The sp_create_staff procedure is not created due to severe error b. The sp_create_staff procedure is created with a warning error c. The sp_create_staff procedure is created without any kind of errors d. The sp_use_jobs procedure is automatically created before sp_create_staff procedure is created e. only warning error if another stored procedure object is mising Ans : b 122. Consider the following statements: CREATE PROC myproc @parm1 int = 100, @parm2 int = 200, @parm3 int = 300 AS ----processing done here RETURN The above PROC is executed twice as below: 1) EXEC myproc 2) EXEC myproc @parm1 = DEFAULT, @parm2 = 5, @parm3 = 6 What are the value of parameters passed to myproc in both the cases? a. With 1) parm1 = 0, parm2 = 0, parm3 = 0 With 2) parm1 = 100, parm2 = 5, parm3 = 6 b. With 1) Gives error due to incorrect parameter passing With 2) parm1 = 100, parm2 = 5, parm3 = 6 c. With 1) parm1 = 100, parm2 = 200, parm3 = 300 With 2) parm1 = 100, parm2 = 5, parm3 = 6 d. With 1) parm1 = 100, parm2 = 200, parm3 = 300 With 2) parm1 = 0, parm2 = 5, parm3 = 6 e. With 1) parm1 = 100, parm2 = 200, parm3 = 300 With 2) Gives error due to invalid parameter passing f. default parameters in first case and second case only parm1 is default Ans : c 123. Consider the following : CREATE proc advance_range (@low money, @high money) WITH RECOMPILE AS SELECT * FROM dbo.titles where advance between @low and @high RETURN Which of the following are valid ways of executing the above proc in case recompilation of query plan is required before executing? (Choose 2) 124.Consider the following : DECLARE @avg1 money, DECLARE @avg2 money, DECLARE @avg3 money SELECT @avg1 = dbo.averagebookprice('computers') SET @avg2 = dbo.averagebookprice('computers') EXEC @avg2 = dbo.averagebookprice 'computers'

SELECT @avg1 as avg1, @avg2 as avg2, @avg3 as avg3 GO Assume that averagebookprice is a user defined scalar function that returns a value of 100.09 for 'computers' which of the following is a correct statement? a. avg1 will be 100.09, avg2 will be 100 and avg3 will be 100.10 b. avg1 will be 100.09, avg2 will be 100.09 and avg3 will be 100.09 c. avg1 will be 100, avg2 will be 100.09 and avg3 will be 100.10 d. avg1 will be 100.10, avg2 will be 100 and avg3 will be 100.09 e. avg1 will be 100, avg2 will be 100 and avg3 will be 100 f. All the three are equivalent and perform same function Ans : b 125. 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? a. avg1 will be displayed as 100 b. avg1 will be displayed as 100.09 c. There will be execution error in the statements d. avg1 will be displayed as 100.10 e. since the schema name is missing, there will be execution error f. since the schema name is missing, there will be execution error Ans : c 126. Consider the following example of a multi-statement table valued function in which some important statements are missing: CREATE FUNCTION averagepricebytype(@ price money = 0.0 RETURNS @table AS Insert @table SELECT type, avg(isnull(price, 0)) as avg_price FROM titles GROUP BY type HAVING avg(isnull(price, 0) > @price RETURN Which of the following explains the missing statements to be included in above?(Choose 2) a. Include BEGIN.END as wrappers around the statements the function contains. b. Include the clause 'MULTI-STATEMENT TABLE' in the CREATE statement c. Include DO.END as wrappers around the statements the function contains. d. Define the structure of the table rowset that you are returning e. begin end is a must for multi stmt table function, also table structure definition Ans : a 127.Consider the following example of a multi-statement table valued function: CREATE FUNCTION averagepricebytype(@ price money = 0.0 RETURNS @table table(type varchar(12) null, avg_price money null) AS BEGIN Iinsert @table SELECT type, avg(isnull(price, 0)) as avg_price FROM titles GROUP BY type HAVING avg(isnull(price, 0) > @price RETURN

END Which of the following example is correct to invoke the above function? a. Select * from multi-statement table function averagepricebytype(15) b. Select * from averagepricebytype(15) c. Select * from averagepricebytype(15) using multi-statement table function d. Select * from function averagepricebytype(15) e. simple reference to function is enough to use it Ans : b 128. Consider the following example of a multi-statement table valued function: CREATE FUNCTION averagepricebytype(@ price money = 0.0 RETURNS @table table(type varchar(12) null, avg_price money null) with schemabinding AS BEGIN Iinsert @table SELECT type, avg(isnull(price, 0)) as avg_price FROM titles GROUP BY type HAVING avg(isnull(price, 0) > @price RETURN END The following command is issued on the table 'titles' that is used in the function above: ALTER table titles alter column price smallmoney null Which of the following happens upon executing the ALTER command? a. The ALTER command fails b. The price column is changed c. The price column is changed only if no user is using the averagepricebytype function when the ALTER command is issued e. None of the listed options d. cannot alter when the column is used in a function Ans : a 129.Consider the following Function: CREATE FUNCTION striptime(@datetimeval datetime) RETURNS datetime WITH RETURNS NULL ON NULL INPUT AS BEGIN DECLARE @dateval datetime SELECT @dateval = convert(char(10), isnull@datetimeval), getdate()), 110) RETURN @dateval END Which of the following happens when the above function is invoked with NULL input? a. The FUNCTION body gets executed and NULL is returned as result b. The FUNCTION body does not get executed and the value of NULL is returned c. The FUNCTION returns error if input is NULL e. None of the listed options Ans : b 130.Consider the following function creation: CREATE FUNCTION dbo.getonlydate() RETURNS datetime as BEGIN DECLARE @date datetime SET @date = dbo.striptime(getdate()) RETURN @date

END Assume 'striptime' is another function already created. Which of the following statement is correct for the above create function? a. The CREATE function is not valid and gives error b. The CREATE function is valid but will give execution error that striptime is not found c. The CREATE function is valid and will not give any execution error on existence of striptime function. d. None of the listed options e. one function can call another - nesting ans : c

131.Consider the following function creation: CREATE FUNCTION dbo.getonlydate() RETURNS datetime as BEGIN DECLARE @date datetime SET @date = getdate() RETURN @date END Which of the following happens due to the use of non-deterministic function getdate() in the above UDF? a. The CREATE function is not valid and gives error b.The CREATE function is valid but will give execution error because of use of non-deterministic function getdate() c. The CREATE function is valid and will not give any execution error on use of getdate() d. None of the listed options e. getdate() valid built in non-deterministic function to be used Ans : c 132. Consider the following function creation: CREATE FUNCTION dbo.getonlydate() RETURNS datetime as BEGIN DECLARE @date datetime, @randomdata int SET @date = getdate() SET @randomdata = rand() RETURN @date END Which of the following happens due to the use of non-deterministic functions getdate() and rand() in the above UDF? a. The CREATE function is not valid and gives error b. The CREATE function is valid but gives execution error on use of rand() c. The CREATE function is valid but gives execution error on use of getdate() d. None of the listed options e.rand() is not a valid builtin non-deterministic function that can be used Ans : a 133. 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? a. It creates a valid in-line table valued function b. Create fails because it is an invalid type of table valued function

c. Create fails because it is an invalid type of scalar function d. None of the listed options e. inline table function valid type Ans : a 134.Consider the following sequence of commands for functions: CREATE FUNCTION averagepricebytype(@price money = 0.0) RETURNS TABLE AS RETURN (SELECT type, avg(isnull(price, 0)) as avg_price FROM titles GROUP BY type HAVING avg(isnull(price, 0)) > @price) ALTER FUNCTION averagepricebytype(@price money = 0.0) RETURNS @table table(type varchar(12) null, avg_price money null) AS BEGIN Iinsert @table SELECT type, avg(isnull(price, 0)) as avg_price FROM titles GROUP BY type HAVING avg(isnull(price, 0)) > @price RETURN END Which of the following statement is correct for the above statements? a.The CREATE fails but ALTER succeeds b.The CREATE succeeds but ALTER fails c. Both CREATE and ALTER fails d. CREATE and ALTER go through successfully e.cannot modify function from inline to multi table Ans : b

135. 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? a.The CREATE fails but ALTER succeeds b.CREATE and ALTER go through successfully c. can modify inline function stmts d. Both CREATE and ALTER fails e.CREATE and ALTER go through successfully Ans : b

136. Consider the creation of following stored procedure: CREATE proc check_user_who WITH EXECUTE AS 'Sunil' AS SELECT user_name() as 'User name applicable' GO The following statements are executed: SELECT user_name() as 'User name applicable' EXEC check_user_who What is the result of SELECT in sequence when the above statements are executed? a.User name applicable - dbo User name applicable - Sunil b. User name applicable - dbo User name applicable - dbo c. User name applicable - Sunil User name applicable - dbo d.User name applicable - Sunil User name applicable - Sunil e. execte as overrides the user name to sunil

137.Consider the following stored procedure creation: CREATE proc sp_check_authors AS SELECT au_id, au_name, au_last_title FROM authors WHERE au_id > 1001 GO It so happens that the authors table is dropped and no longer exists in the database. What will be the outcome of the create procedure sp_check_authors as above? a. The sp_check_authors procedure is not created due to severe error b. The sp_check_authors procedure is created with a warning error c. The sp_check_authors procedure is created without any kind of errors d. The authors table is automatically created before sp_check_authors procedure is created e. delayed resolution is permitted, no error during create for table objects Ans : c 138. Consider the following stored procedure creation: CREATE proc sp_check_authors AS SELECT au_id, au_name, au_last_title FROM authors WHERE au_id > 1001 GO It so happens that the authors table is dropped and no longer exists in the database. Now the following statement is issued EXEC sp_check_authors GO What will be the outcome of the above create and execution statements? a. Both Create and execution fails b. Create fails but execution goes through without errors c. Both Create and execution goes through without errors d. Create is successful but execution gives error e. since delayed resolution is possible create goes through, but execution gives error on missing table authors Ans : d 139.Consider the following stored procedure creation:

CREATE proc sp_check_authors AS BEGIN SELECT au_id, au_name, au_last_title FROM authors WHERE au_id > 1001 RETURN GO Now the following statements are issued : EXEC sp_helptext sp_check_authors GO SELECT definition FROM sys.sql_modules WHERE object_id = object_id('sp_check_authors') GO SELECT object_definition (object_id('dbo.sp_check_authors')) GO What will be the outcome of the above statements issued? a. The source code of the stored procedure sp_check_authors is displayed 2 times b. The source code of the stored procedure sp_check_authors is displayed once c. The source code of the stored procedure sp_check_authors is displayed once d. The source code of the stored procedure sp_check_authors is displayed 3 times e. All three stmts can be used to display source code, so 3 times Ans : d 140. Consider the following statements: ALTER PROC insert_items @item_id char(4), @item_name varchar(40) as BEGIN TRY INSERT INTO comp1.dbo.itemmaster (item_id, item_name) VALUES(@item_id, @item_name) print New Item added END TRY BEGIN CATCH exec error_handler RETURN -101 END CATCH RETURN 0 What is the return code if the following statement is executed? EXEC insert_items ABCDEFGH, Gear Assembly a. 0 b.-101 c. NULL d. -1 e. None of the listed options Ans : b

141. Consider the following statements: CREATE PROC sales_till_date @title varchar(100), @ytd_sales int OUTPUT

AS SELECT @ytd_sales = ytd_sales FROM titles where title = @title RETURN The above proc is executed as follows: DECLARE @sales_upto_today int EXEC sales_till_date 'My experiments with truth', @sales_upto_today Print 'Sales this year until today :' + CONVERT(varchar(10), @sales_upto_today What is the outcome of executing as above? Ans: a) 0 b) -101 c) null d) -1 e) None of the above 142. Consider the following statements: CREATE PROC sales_till_date @title varchar(100), @ytd_sales int OUTPUT AS SELECT @ytd_sales = ytd_sales FROM titles where title = @title RETURN The above proc is executed as follows: DECLARE @sales_upto_today int EXEC sales_till_date 'My experiments with truth', @sales_upto_today Print 'Sales this year until today :' + CONVERT(varchar(10), @sales_upto_today What is the outcome of executing as above? a) The year to date sales as picked up from the titles table will be correctly displayed for the book 'My experiments with truth' b) The year to date sales as picked up from the titles table will not be correctly displayed for the book 'My experiments with truth' (not sure with this answer it was not marked yellow but the field was marked Y) c) The PROC will give error while executing d) None of the listed options

143. Consider the following statements: Assume table 'titles' exists with following books only: Life without fear My experiments with truth Gone with the wind CREATE PROC ytd_sales2 @title varchar(80) AS IF NOT EXISTS (SELECT * FROM titles WHERE title = @title) RETURN -111 SELECT ytd_sales from titles where title = @title RETURN GO The above PROC is executed as follows: DECLARE @status INT EXEC @status = ytd_sales2 'Life without fear' IF @status = -111 PRINT 'No book with that name found' GO EXEC @status = ytd_sales2 'Undefeated' GO EXEC @status = ytd_sales2 'Gone with the wind' IF @status = -111 PRINT 'No book with that name found' GO How many times the message 'No book with that name found'' will be displayed for the above scenario? a) once b) twice c) none d) thrice 144. Consider the following statements: CREATE PROC pub_test AS SELECT pub_id, pub_name, city, statecd into ##temp from publishers where statecd in ('MH', 'AP', 'TN') SELECT pub_id, pub_name, city, statecd into #temp from publishers where statecd in ('MH', 'AP', 'TN') GO The following sequence of execution statements are made: EXEC pub_test GO SELECT * from ##temp

-----1

SELECT * from #temp EXEC pub_test GO SELECT * from ##temp

-----2

------3

What is the correct sequence of outcome on executing the SELECT statements marked 1,2 3 as above? a) 1) The contents of temp table are correctly displayed 2) The contents of temp table are correctly displayed 3) Error message displayed b) 1) Error message displayed 2) The contents of temp table are correctly displayed 3) Error message displayed c) 1) The contents of temp table are correctly displayed 2) Error message displayed 3) Error message displayed d) 1) The contents of temp table are correctly displayed 2) Error message displayed 3) The contents of temp table are correctly displayed 145. Consider the following statements: CREATE PROC pub_test AS SELECT pub_id, pub_name, city, statecd into ##temp from publishers where statecd in ('MH', 'AP', 'TN') SELECT pub_id, pub_name, city, statecd into #temp from publishers where statecd in ('MH', 'AP', 'TN') GO The following sequence of execution statements are made: EXEC pub_test GO SELECT * from ##temp SELECT * from #temp DROP table ##temp EXEC pub_test GO SELECT * from ##temp

------- 1 ------- 2

-------- 3

What is the correct sequence of outcome on executing the SELECT statements marked 1,2,3 as above? a) 1) The contents of temp table are correctly displayed 2) The contents of temp table are correctly displayed 3) Error message displayed

b) 1) Error message displayed 2) The contents of temp table are correctly displayed 3) Error message displayed c) 1) The contents of temp table are correctly displayed 2) Error message displayed 3) Error message displayed d) 1) The contents of temp table are correctly displayed 2) The contents of temp table are correctly displayed 3) The contents of temp table are correctly displayed 146. Consider the following scenario example: CREATE PROC find_books_by_type @typelist varchar(8000) AS EXEC('select title_id, title = substring(title, 1, 40), type, price FROM titles where type in ('+ @typelist + ') order by type, title_id') GO set quoted_identifier off The stored procedure is executed as below: EXEC find_books_by_type "'business', 'mod_cook', 'trad_cook'" GO Which of the following are correct statements for the above scenario?(Choose 2) a) The nested stored procedure concept is used b) Variable list of values can be passed into the stored procedure c) It uses dynamic sql query within a stored procedure d) Only three values can be passed into the stored procedure 147. Consider the following Stored procedures created: CREATE PROC get_titles_data_by_price(@flag tinyint, @value money) AS select * from titles where price = @value GO CREATE PROC get_titles_data_by_advance(@flag tinyint, @value money) AS select * from titles where advance = @value GO CREATE PROC get_titles_data(@flag tinyint, @value money) AS if @flag = 1 exec get_titles_data_by_price @value else exec get_titles_data_by_advance @value Which of the following stored procedure is functionally equivalent to the above set of stored procedures?

a) CREATE PROC get_titles_data_by_price(@flag tinyint, @value money) AS exec get_titles_data @value GO CREATE PROC get_titles_data_by_advance(@flag tinyint, @value money) AS exec get_titles_data @value GO CREATE PROC get_titles_data(@flag tinyint, @value money) AS if @flag = 1 exec get_titles_data_by_price @value else exec get_titles_data_by_advance @value b) CREATE PROC get_titles_data(@flag tinyint, @value money) AS Select * from titles where price = @value or advance = @value c) CREATE PROC get_titles_data(@flag tinyint, @value money) AS if @flag = 1 select * from titles where price = @value else select * from titles where advance = @value d) None of the listed options

148. Consider the following statements: CREATE PROC myproc @parm1 int1, @parm2 int, @parm3 int AS ----processing done here RETURN The above PROC is executed twice as below: 1) EXEC myproc 2) EXEC myproc @parm1 = 6 What is the outcome of executing the above ? a) 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 b) 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 c) With 1) parameters passed: parm1 = 0, parm2 = 0, parm3 = 0 With 2) Gives error - Procedure 'myproc' expects parameter '@parm2' which was not supplied

d) With 1) parameters passed: parm1 = 0, parm2 = 0, parm3 = 0 With 2) parameters passed: parm1 = 6, parm2 = 0, parm3 = 0 149. Consider the following stored procedures: CREATE proc main_proc AS exec sub_proc1 exec sub_proc3 exec sub_proc2 return go CREATE proc sub_proc1 AS exec sub_proc2 go CREATE proc sub_proc2 AS exec proc sub_proc3 return CREATE proc sub_proc3 AS exec sub_proc1 return What will be the outcome upon invoking EXEC main_proc?

a) sub_proc1 will be executed only once b) sub_proc2 will be executed 3 times c) sub_proc3 will be executed 2 times d) sub_proc1, sub_proc2, sub_proc3 will be executed 32 times each e) None of the listed options 150. 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?

a) EXEC SelectByIdList @productIds='<Products><id>3</id><id>6</id><id>15</id></Products>' b) EXEC SelectByIdList @productIds='P001' c) EXEC SelectByIdList @productIds='P001' and productIds='P002' d) EXEC SelectByIdList 151. Which of the following is the Highest isolation level in SQL Server 2005? a) Read uncommitted b) Read Committed c) Repeatable Read d) Serializable 152. Distributed queries allow you to collect and manipulate data from __________________________ a) more than one table in a database b) multiple SQL Server databases on a server c) multiple OLE DB datasources d) None of the listed options 153. You are writing a distributed query to query data from another SQL Server database. What is the fully qualified naming convention?

a) linked_server_name.database.owner.table b) linked_server_name.database.table c) linked_server_nametable d) database.table 154. You are writing a distributed query to query data from an Access database. What is the fully qualified naming convention? a) Access_server_name.database.owner.table b) Access_server_name.owner.table c) Access_server_name...table d) None of the listed options 155. 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?

a) It sends a Rollback command to all three resource managers b) It sends a rollback command to the server that reported a failure to prepare c) Commit is issued as majority of servers reported successful prepare d) Name of the server which failed to prepare, is logged for repair work by DBA 156. 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? a) Ora_db is delinked from the SQL server b) The changes of Ora_db are notified to the SQL server c) The databases become semi-linked d) None of the listed options 157. Which of the following the datasource must conform to in order to be a linkedserver? a) It must be a SQL Server 2005 b) It must be a database supplied by Microsoft (eg., Access, Excel) c) It must be a OLE DB compliant data source d) It must be a Relational Database 158. Which of the following is the use of sp_linkedservers command?

a) It allows you to define a linked server on the local server b) It allows you to display the list of linked servers defined on the local server c) It allows you to specify a login id that links the servers d) It activates the link between the servers 159. For which of the following is a two-phase commit, consisting of prepare and commit used? a) Transactions that might require a rollback b) Transactions updating multiple tables c) Distributed transactions d) Transactions requiring user confirmation of update 160. Which of the following is correct for a shared lock? a) It is a lock acquired by a process on the resources that it intends to modify b) It is a lock acquired by a process on a resource prior to modifying it

c) It is lock acquired by a process on a resource for the duration of read d) None of the listed options 161. 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. TRUE FALSE 162. When a SELECT * command is executed on a table, when is the shared lock on the first row released? After all the rows are read After the first row is read After the second row is read Only when the transaction is committed or rolled back 163. 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. TRUE FALSE 164. Consider the following scenario: A Table 'book' has the following records id title -------2 Catch-22 3 Roses in December 4 My experiments with Truth Assume a default isolation level of 'READ COMMITTED' for the following commands. User1 has issued the following commands BEGIN TRAN SELECT title FROM book where id = 2; User2 has now issued the following commands SELECT title FROM book where id = 2; What will be the outcome? User2 will be blocked User2 will not be blocked and both will proceed User1's transaction is blocked and user2 will proceed There will be a deadlock 165. Consider the following scenario: A Table 'book' has the following records id title -------2 Catch-22 3 Roses in December 4 My experiments with Truth Assume a default isolation level of 'READ COMMITTED' for the following commands. User1 has issued the following commands BEGIN TRAN

SELECT title FROM book WITH (UPDLOCK) where id = 2; User2 has now issued the following commands SELECT title FROM book where id = 2; What will be the outcome? User2 will be blocked User2 will not be blocked and both will proceed User1's transaction is blocked and user2 will proceed There will be a deadlock No block because Update lock is compatible with Shared lock 166. Consider the following scenario: A Table 'book' has the following records id title -------2 Catch-22 3 Roses in December 4 My experiments with Truth Assume a default isolation level of 'READ COMMITTED' for the following commands. User1 has issued the following commands BEGIN TRAN SELECT title FROM book WITH (UPDLOCK) where id = 2; User2 has now issued the following commands SELECT title FROM book WITH (UPDLOCK) where id = 2; What will be the outcome? User2 will be blocked User2 will not be blocked and both will proceed User1's transaction is blocked and user2 will proceed There will be a deadlock Only one transaction can have the update lock on row 2. 167. Consider the following scenario: A Table 'book' has the following records id title -------2 Catch-22 3 Roses in December 4 My experiments with Truth Assume a default isolation level of 'READ COMMITTED' for the following commands. User1 has issued the following commands BEGIN TRAN SELECT title FROM book WITH (UPDLOCK) where id = 2; User2 has now issued the following commands SELECT title FROM book WITH (UPDLOCK) where id = 3; What will be the outcome? User2 will be blocked User2 will not be blocked and both will proceed User1's transaction is blocked and user2 will proceed There will be a deadlock No block as the locks are on separate records

168. Consider the following scenario: A Table 'book' has the following records id title -------2 Catch-22 3 Roses in December 4 My experiments with Truth Assume a default isolation level of 'READ COMMITTED' for the following commands. User1 has issued the following commands BEGIN TRAN SELECT title FROM book where id = 2; User2 has now issued the following commands UPDATE book SET title = 'Roses in December, Second edition' WHERE id = 2 What will be the outcome? User2 will be blocked User2 will not be blocked and both will proceed User1's transaction is blocked and user2 will proceed There will be a deadlock Read Committed isolation level drops the shared lock in Transaction A after the read. 169. Consider the following scenario: A Table 'book' has the following records id title -------2 Catch-22 3 Roses in December 4 My experiments with Truth Assume a default isolation level of 'READ COMMITTED' for the following commands. User1 has issued the following commands BEGIN TRAN UPDATE book SET title = 'Roses in December, Second edition' WHERE id = 2 User2 has now issued the following commands SELECT title FROM book WHERE id = 2 What will be the outcome? User2 will be blocked User2 will not be blocked and both will proceed User1's transaction is blocked and user2 will proceed There will be a deadlock User2 cannot get the shared lock on the key until User1 gives up its exclusive lock. 170. Consider the following scenario: A Table 'book' has the following records id title -------2 Catch-22 3 Roses in December 4 My experiments with Truth Assume a default isolation level of 'READ COMMITTED' for the following commands. User1 has issued the following commands

BEGIN TRAN SELECT title FROM book WITH (UPDLOCK, HOLDLOCK) WHERE id = 2 User2 has now issued the following commands SELECT title FROM book WHERE id = 2 What will be the outcome? User2 will be blocked User2 will not be blocked and both will proceed User1's transaction is blocked and user2 will proceed There will be a deadlock User2 cannot get the shared lock on the key until User1 gives up its exclusive lock. 171. Consider the following scenario: A Table 'book' has the following records id title -------2 Catch-22 3 Roses in December 4 My experiments with Truth Assume a default isolation level of 'READ COMMITTED' for the following commands. User1 has issued the following commands BEGIN TRAN SELECT title FROM book WITH (UPDLOCK, HOLDLOCK) User2 has now issued the following commands INSERT INTO book VALUES(5, 'Harry Potter and the Half-blood Prince') What will be the outcome?

User2 will be blocked User2 will not be blocked and both will proceed User1's transaction is blocked and user2 will proceed There will be a deadlock 172. Consider the following scenario: A Table 'book' has the following records id title -------2 Catch-22 3 Roses in December 4 My experiments with Truth Assume a default isolation level of 'READ COMMITTED' for the following commands. User1 has issued the following commands BEGIN TRAN SELECT title FROM book WITH (UPDLOCK, HOLDLOCK) WHERE title like '%experiments%' User2 has now issued the following commands INSERT INTO book VALUES(6, 'Harry Potter and the Half-blood Prince') What will be the outcome?

User2 will be blocked User2 will not be blocked and both will proceed User1's transaction is blocked and user2 will proceed There will be a deadlock 173. Consider the following scenario: A Table 'book' has the following records id title -------2 Catch-22 3 Roses in December 4 My experiments with Truth Assume a default isolation level of 'READ COMMITTED' for the following commands. User1 has issued the following commands BEGIN TRAN DELETE FROM book WHERE title like '%experiments%' User2 has now issued the following commands INSERT INTO book VALUES(6, 'Harry Potter and the Half-blood Prince') What will be the outcome? User2 will be blocked User2 will not be blocked and both will proceed User1's transaction is blocked and user2 will proceed There will be a deadlock 174. Consider the following scenario: A Table 'book' has the following records id title -------2 Catch-22 3 Roses in December 4 My experiments with Truth Assume a Isolation level of 'READ_COMMITTED_SNAPSHOT' for the following commands. User1 has issued the following commands BEGIN TRAN UPDATE book SET title = 'Roses in December, Second edition' WHERE id = 2 User2 has now issued the following commands SELECT title FROM book WHERE id = 2 What will be the outcome? User2 will be blocked User2 will not be blocked and both will proceed User1's transaction is blocked and user2 will proceed There will be a deadlock 175. Consider the following code: BEGIN TRAN DELETE FROM TABLE1 BEGIN TRAN INSERT INTO TABLE2 COMMIT

UPDATE TABLE3 COMMIT If the update to table3 failed, what will be the outcome? DELETE from TABLE1 and INSERT into TABLE2 are committed INSERT into TABLE2 alone is committed None of the changes to database are committed None of the listed options 176. The PLAYER table contains these columns : id int(9) name varchar(2) manager_id int(9) In this instance, managers are also players whom you need to display as a list. Evaluate these TWO SQL statements: Statement 1: SELECT p.name,m.name FROM player p,player m WHERE m.manager_id=p.id; Statement 2: SELECT p.name,m.name FROM player p,player m WHERE m.manager_id=p.id; Which of the following is applicable for the above statements? 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. The results of these queries will be same, just will look different. In first statement driving column is ID, in second -MANAGER_ID. 177. 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 ____________. ReadUncommitted Committed SnapShot Consistency 178. Consider the following construct: WHILE (1=1) BEGIN PRINT 'I am here in one' IF 1 = 1 BEGIN PRINT 'I am here in two' BREAK END ELSE BEGIN CONTINUE END

END What is the outcome of executing the above? Prints 'I am here in one' Prints 'I am here in two' Prints 'I am here in one' Prints 'I am here in two' Prints 'I am here in one' Prints 'I am here in two' Prints 'I am here in one'

Prints nothing BREAK will break the loop since 1 = 1 179. Consider the following construct: WHILE (1=1) BEGIN PRINT 'I am here in one' IF 1 = 1 BEGIN PRINT 'I am here in two' END ELSE BEGIN CONTINUE END END How many times the message 'I am here in one' will be printed on executing above? Once 2 times zero times 3 times None of the listed options End less loop 180. Consider the following statements as part of a stored procedure: WAITFOR DELAY '02:00:22' BEGIN EXEC sp_process_total_one WAITFOR TIME '02:00:22' BEGIN EXEC sp_process_total_two END Supposing the above procedure is is run exactly at midnight, what is the expected outcome? 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 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 "Consider the following cursor processing:

181

DECLARE authors_cursor FORWARD_ONLY FOR SELECT au_lname, au_fname FROM authors ORDER BY au_lname, au_fname OPEN authors_cursor FETCH FIRST FROM authors_cursor FETCH RELATIVE 3 FROM authors_cursor FETCH RELATIVE -2 FROM authors_cursor CLOSE authors_cursor DEALLOCATE authors_cursor (Assume that authors table has 200 author profiles) What is the outcome of executing the above cursor statements?" 1 2 3 4 182 Three author profiles are retrieved from authors One author profile is retrieved from authors No author profiles are retrieved from authors Gives execution error cannot use relative, with forward_only cursor

Consider the following cursor processing:

DECLARE authors_cursor SCROLL FOR SELECT au_lname, au_fname FROM authors ORDER BY au_lname, au_fname OPEN authors_cursor FETCH NEXT FROM authors_cursor FETCH ABSOLUTE 20 FROM authors_cursor FETCH RELATIVE 3 FROM authors_cursor FETCH RELATIVE -7 FROM authors_cursor FETCH FIRST FROM authors_cursor CLOSE authors_cursor DEALLOCATE authors_cursor (Assume that authors table has 200 author profiles) How many unique rows are retrieved upon executing the above cursor statements?" 1 Five Four Three

2
3

4 5 6

Six None of the listed options Next and first retrive same rows Consider the following cursor processing statements:

183

DECLARE Employee_Cursor CURSOR READ_ONLY FOR SELECT LastName, FirstName, status FROM dbo.Employees WHERE LastName like 'B%' OPEN Employee_Cursor FETCH NEXT FROM Employee_Cursor PRINT @@FETCH_STATUS WHILE @@FETCH_STATUS = 0 BEGIN FETCH NEXT FROM Employee_Cursor PRINT @@FETCH_STATUS END CLOSE Employee_Cursor DEALLOCATE Employee_Cursor (Assume that the Employees table has 500 rows of employee data) What is the value of @@FETCH_STATUS printed in the last print statement as per above? 1 2 3 4 184 0 1 -1 2 "Consider the following cursor processing statements:

DECLARE @cba CURSOR DECLARE abc CURSOR GLOBAL SCROLL FOR SELECT * FROM authors SET @cba = abc OPEN abc FETCH NEXT FROM @cba FETCH NEXT FROM abc FETCH NEXT FROM @cba CLOSE @cba DEALLOCATE abc In case the authors table had 100 author profiles, how many authors will get retrieved as per above processing?" 1 Two

2
3 4 5 185

Three One None Gives error message both cursor and cursor variable used interchangeably

Consider the following cursor processing statements:

DECLARE Employee_Cursor CURSOR FAST_FORWARD FOR SELECT LastName, FirstName, status FROM dbo.Employees WHERE LastName like 'B%' FOR UPDATE OPEN Employee_Cursor FETCH NEXT FROM Employee_Cursor WHILE @@FETCH_STATUS = 0 BEGIN DELETE Employees WHERE current of Employee_Cursor FETCH NEXT FROM Employee_Cursor END CLOSE Employee_Cursor DEALLOCATE Employee_Cursor (Assume that the Employees table has 500 rows of employee data) What is the outcome of the above cursor processing?" 1 2 3 4 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 fast_forward option Consider the following statements: Cannot update/delete with

186

WHILE (1=1) BEGIN WAITFOR TIME '01:00' EXEC sp_update_stats RAISERROR('Statistics updated for database',1,1) WITH LOG END What is the outcome of the above?" 1 "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" 2 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" 3 1) Updates the statistics for every table in the database only once at 1 A.M while loop keeps it running, and waitfor

4 Gives error message time will make sure at 1 am the update is done 187

Consider the following cursor processing statements:

DECLARE authors_cursor CURSOR FOR SELECT au_id, au_fname, au_lname FROM authors WHERE state = 'UT' ORDER BY au_id OPEN authors_cursor IF @@CURSOR_ROWS = 0 END FETCH NEXT FROM authors_cursor IF @@FETCH_STATUS = -1 PRINT 'NO ROWS FOUND' END WHILE @@FETCH_STATUS = 0 BEGIN PRINT 'ATLEAST ONE ROW FOUND ' FETCH NEXT FROM authors_cursor END END CLOSE authors_cursor DEALLOCATE authors_cursor What is the message that gets printed in case the authors table does not have any rows satisfying the given condition?" 1 2 3 Prints message 'NO ROWS FOUND' Y Prints message 'ATLEAST ONE ROW FOUND' Prints no message Y since cursor check does not do

4 Gives error message anything, message dispalyed for fetch status check 188

Consider the following cursor processing statements:

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

In case the authors table had 100 author profiles, how many authors will get retrieved as per above processing?" 1 2 3 4 5 Two Three One None Gives error message error occurs Y Since cursor variable is not set to cursor ,

189

Consider the following statements:

SELECT deptid, name, groupname, CASE WHEN groupname = 'Marketing' THEN 'Room 1' WHEN groupname = 'Human Resources' THEN 'Room 2' WHEN groupname = 'Production' THEN 'Room 3' ELSE 'Room 4' END FROM hr.department Which of the following is correct equivalent to the above?" 1 "SELECT deptid, name, groupname, CASE groupname WHEN 'Marketing' THEN 'Room 1' WHEN 'Human Resources' THEN 'Room 2' WHEN 'Production' THEN 'Room 3' ELSE 'Room 4' END FROM hr.department" 2 Y

SELECT deptid, name, groupname,

CASE WHEN groupname 'Marketing' THEN 'Room 1' WHEN groupname 'Human Resources' THEN 'Room 2' WHEN groupname 'Production' THEN 'Room 3' ELSE 'Room 4' END FROM hr.department" 3 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' END FROM hr.department" 4 190 None of the listed options Consider the following scenario:

A proc is created as follows: CREATE PROC cursor_proc @cursor CURSOR VARYING OUTPUT AS DECLARE curs1 CURSOR GLOBAL FOR SELECT cast(title as varchar(30)) as title, pubdate from titles set @cursor = curs1 open curs1 return go Now the following statements are executed: DECLARE @curs CURSOR EXEC cursor_proc @cursor = @curs output fetch curs1 fetch @curs close curs1 deallocate curs1

fetch @curs open @curs go What is the outcome of the last fetch and open statements in above?" 1 Fetch and Open both fail Fetch fails but open succeeds Fetch succeeds but open fails Fetch and open both succeed fully dealocated Consider the following scenario: open succeeds since not Y

2
3 4

191

A proc is created as follows: CREATE PROC cursor_proc @cursor CURSOR VARYING OUTPUT AS DECLARE curs1 CURSOR GLOBAL FOR SELECT cast(title as varchar(30)) as title, pubdate from titles set @cursor = curs1 open curs1 return go Now the following statements are executed: DECLARE @curs CURSOR EXEC cursor_proc @cursor = @curs output fetch curs1 fetch @curs close curs1 deallocate curs1 fetch @curs open @curs fetch @curs close @curs deallocate @curs open @curs go What is the outcome of the last fetch and open statements in the above statements?" 1 2 Fetch and Open both fail Fetch fails but open succeeds Fetch succeeds but open fails Fetch and open both succeed the end, cannot open after that Y since fully deallocated at

3
4

192

Consider the following scenario:

A proc is created as follows: CREATE PROC cursor_proc @cursor CURSOR VARYING OUTPUT AS DECLARE curs1 CURSOR GLOBAL FOR SELECT cast(title as varchar(30)) as title, pubdate from titles set @cursor = curs1 open curs1 return go Now the following statements are executed: DECLARE @curs CURSOR EXEC cursor_proc @cursor = @curs output fetch curs1 fetch @curs close curs1 deallocate curs1 deallocate curs fetch @curs open @curs go What is the outcome of the last fetch and open statements in the above statements?" 1 2 3 Fetch and Open both fail Y Fetch fails but open succeeds Fetch succeeds but open fails since both references are

4 Fetch and open both succeed deallocated, cannot fetch or open 193 Consider the following scenario:

A proc is created as follows: CREATE PROC cursor_proc @cursor CURSOR VARYING OUTPUT AS DECLARE curs1 CURSOR GLOBAL FOR SELECT cast(title as varchar(30)) as title, pubdate from titles set @cursor = curs1 open curs1 return go Now the following statements are executed: DECLARE @curs CURSOR EXEC cursor_proc @cursor = @curs output fetch curs1 fetch @curs close curs1

deallocate curs1 fetch @curs open @curs fetch @curs close @curs open @curs go What is the outcome of the last fetch and open statements in the above statements?" 1 2 3 Fetch and Open both fail Fetch fails but open succeeds Fetch succeeds but open fails Fetch and open both succeed works Y since not deallocated, open

4
194

Consider the following cursor processing:

DECLARE authors_cursor FAST_FORWARD FOR SELECT au_lname, au_fname FROM authors ORDER BY au_lname, au_fname OPEN authors_cursor FETCH NEXT FROM authors_cursor FETCH NEXT FROM authors_cursor FETCH NEXT FROM authors_cursor FETCH NEXT FROM authors_cursor CLOSE authors_cursor DEALLOCATE authors_cursor (Assume that authors table has 200 author profiles) What is the outcome of executing the above cursor statements?" 1 2 3 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 Gives error message Y

4
5 195

fast forward allows next

Consider the following cursor processing:

DECLARE authors_cursor FAST_FORWARD FOR SELECT au_lname, au_fname FROM authors ORDER BY au_lname, au_fname OPEN authors_cursor FETCH NEXT FROM authors_cursor FETCH RELATIVE 7 FROM authors_cursor

FETCH ABSOLUTE 5 FROM authors_cursor FETCH LAST FROM authors_cursor CLOSE authors_cursor DEALLOCATE authors_cursor (Assume that authors table has 200 author profiles) What is the outcome of executing the above cursor statements?" 1 2 3 4 5 196 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 Gives error message Y with fast forward next only is allowed

Consider the following temporary stored procedure:

CREATE PROCEDURE #use_temp AS SELECT 1/0 RETURN @@ERROR GO The following statements are executed in a procedure: IF NOT EXISTS(SELECT productid FROM production.product WHERE color = 'yellow' ) BEGIN RETURN END SELECT productid FROM production.product WHERE color = 'yellow' DECLARE @ErrorCode INT EXEC @ErrorCode INT = #use_temp PRINT @ErrorCode Assuming that there is no product with yellow color, what is the final outcome of executing as above?" 1 Prints error message and error code

2
3 4

Executes with no message Severe database error None of the listed options returns no message

since not exists is satisfied,just

197

Consider the following temporary stored procedure:

CREATE PROCEDURE #use_temp AS SELECT 1/0 RETURN @@ERROR

GO The following statements are executed in a procedure: IF NOT EXISTS(SELECT productid FROM production.product WHERE color = 'yellow' ) BEGIN RETURN END SELECT productid FROM production.product WHERE color = 'red' DECLARE @ErrorCode INT EXEC @ErrorCode INT = #use_temp PRINT @ErrorCode Assuming that the database has products with red, yellow and blue colors, what is the final outcome of executing as above?" 1 Prints error message and error code Y 2 3 Executes with no message Severe database error since temp proc is invoked, it gives

4 None of the listed options divide by 0 error and error message is printed 198 Consider the following statements:

SELECT deptid, name, groupname, CASE groupname WHEN 'Marketing' THEN 'Room 1' WHEN 'Human Resources' THEN 'Room 2' WHEN 'Production' THEN 'Room 3' ELSE 'Room 4' END FROM hr.department Which of the following is correct equivalent to the above?" 1 "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' END

FROM hr.department" 2 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' END FROM hr.department" 3 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' END FROM hr.department" 4 SELECT deptid, name, groupname, CASE WHEN groupname = 'Marketing' THEN 'Room 1' WHEN groupname = 'Human Resources' THEN 'Room 2' WHEN groupname = 'Production' THEN 'Room 3'

ELSE 'Room 4' END FROM hr.department" 5 199 Y regular case is converted to boolean case as in 4

None of the listed options

Consider the following cursor processing:

The following procedures are created: CREATE PROC sp_two AS SET NO COUNT ON FETCH C1 RETURN GO CREATE PROC sp_one AS SET NO COUNT ON DECLARE CURSOR C1 GLOBAL FOR SELECT titleid, type from titles OPEN C1 FETCH C1 EXEC sp_two CLOSE C1 DEALLOCATE C1 GO (Assume that titles table has 100 book titles) How many book titles are retrieved when proc sp_one is executed?" 1 One book title Two book titles None Gives execution error sp_two works Consider the following cursor processing: since global cursor is declared, fetch in Y

2
3 4

200

The following procedures are created: CREATE PROC sp_two AS SET NO COUNT ON FETCH C1 RETURN GO

CREATE PROC sp_one AS SET NO COUNT ON DECLARE CURSOR C1 LOCAL FOR SELECT titleid, type from titles OPEN C1 FETCH C1 EXEC sp_two CLOSE C1 DEALLOCATE C1 GO (Assume that titles table has 100 book titles) What are the possible outcomes when proc sp_one is executed?(Choose 2)" 1 2 3 One row is fetched from titles Two rows are fetched from titles No rows are fetched from titles since local cursor used, only one Y

4 Gives error message Y row, and sp_two gives error that c1 is invalid

201. Consider the following cursor processing: The following procedures are created: CREATE PROC sp_two AS SET NO COUNT ON DECLARE CURSOR C1 LOCAL FOR SELECT au_id, au_name form authors OPEN C1 FETCH C1 CLOSE C1 DEALLOCATE C1 RETURN GO CREATE PROC sp_one AS SET NO COUNT ON DECLARE CURSOR C1 LOCAL FOR SELECT titleid, type from titles OPEN C1 FETCH C1 EXEC sp_two

CLOSE C1 DEALLOCATE C1 GO What is the possible outcome when proc sp_one is executed? No 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 Y Gives execution error message Local cursors can be with same name, hence valid and one row fetched from authors and titles each 202. Consider the following cursor processing: The following procedures are created: CREATE PROC sp_two AS SET NO COUNT ON DECLARE CURSOR C2 GOBAL FOR SELECT au_id, au_name form authors OPEN C2 RETURN GO CREATE PROC sp_one AS SET NO COUNT ON DECLARE CURSOR C1 LOCAL FOR SELECT titleid, type from titles OPEN C1 FETCH C1 EXEC sp_two FETCH C2 CLOSE C1 DEALLOCATE C1 CLOSE C2 DEALLOCATE C2 RETURN

GO (Assume that titles table has 100 book titles and authors table has 200 author profiles) What is the possible outcome when proc sp_one is executed??? 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 Since cursor is open, fetch of c2 from sp_one should work 203. Consider the following cursor processing: The following procedures are created: CREATE PROC sp_two AS SET NO COUNT ON DECLARE CURSOR C2 GOBAL FOR SELECT au_id, au_name form authors OPEN C2 RETURN GO CREATE PROC sp_one AS SET NO COUNT ON DECLARE CURSOR C1 LOCAL FOR SELECT titleid, type from titles OPEN C1 FETCH C1 EXEC sp_two FETCH C2 CLOSE C1 DEALLOCATE C1 RETURN GO (Assume that titles table has 100 book titles and authors table has 200 author profiles) The above is executed as follows: EXEC sp_one GO

FETCH C2 GO What is the possible outcome of the above execution? 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 since cursor is not deallocated, it is available even after sp_one finishes execution and hence c2 is available for fetch

204. Consider the following cursor processing statements: DECLARE @au_lname varchar(40), @au_fname varchar(20) DECLARE authors_cursor CURSOR [FAST_FORWARD] FOR SELECT au_lname, au_fname FROM authors WHERE au_lname LIKE 'B%' OPEN authors_cursor FETCH NEXT FROM authors_cursor INTO @au_lname, @au_fname WHILE @@FETCH_STATUS = 0 BEGIN PRINT 'Author: ' + @au_fname + ' ' + @au_lname FETCH NEXT FROM authors_cursor INTO @au_lname, @au_fname END CLOSE authors_cursor DEALLOCATE authors_cursor GO In case the authors table has authors with following entries au_lname BHARAT au_fname IYER

ASHISH BIDYUT ANISH BALA

MALHOTRA THAKUR MATRE SUBRAMANIAN

How many author names would have got printed at the end as per the cursor processing above? Five authors Three authors No authors Gives error message 205. Consider the following cursor processing statements: DECLARE authors_cursor CURSOR FOR SELECT au_id, au_fname, au_lname FROM authors WHERE state = 'UT' ORDER BY au_id OPEN authors_cursor IF @@CURSOR_ROWS = 0 BEGIN CLOSE authors_cursor DEALLOCATE authors_cursor RETURN END FETCH NEXT FROM authors_cursor

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

END END CLOSE authors_cursor DEALLOCATE authors_cursor What is the message that gets printed in case the authors table does not have any rows satisfying the given condition? Prints message 'NO ROWS FOUND' Prints message 'ATLEAST ONE ROW FOUND' Prints no message Gives error message Since cursor rows is checked and returned, no message is printed 206. Sham has to convert the rows of the 'Employee' table to a xml file, adhering to the following rules : 1.The values in each row should be the property of the 'row' tag 2.Create another file in which the column name must be the tag name for each value 3.Root tag must have the name as 'ROOT' and each and every row must start with the tag name 'ROW' 4.Root tag must have a property specifying the xml Namespace Per Rule 1, which of the following Centric method should Sham use to create the file? Element Centric Attribute Centric Xml Centric None of the listed options -------------------------------------------------------------------207. Sham has to convert the rows of the 'Employee' table to a xml file, adhering to the following rules : 1.The values in each row should be the property of the 'row' tag 2.Create another file in which the column name must be the tag name for each value 3.Root tag must have the name as 'ROOT' and each and every row must start with the tag name 'ROW'

4.Root tag must have a property specifying the xml Namespace Per the Rule 2, which of the following Query should he use to create a file? SELECT * FROM EMPLOYEE ORDER BY EMPNAME FOR XML RAW SELECT * FROM EMPLOYEE ORDER BY EMPNAME FOR XML RAW ,XSINIL SELECT * FROM EMPLOYEE ORDER BY EMPNAME FOR XML RAW ,ELEMENTS SELECT * FROM EMPLOYEE ORDER BY EMPNAME FOR XML ELEMENTS

208. Sham has to convert the rows of the 'Employee' table to a xml file, adhering to the following rules : 1.The values in each row should be the property of the 'row' tag 2.Create another file in which the column name must be the tag name for each value 3.Root tag must have the name as 'ROOT' and each and every row must start with the tag name 'ROW' 4.Root tag must have a property specifying the xml Namespace Which of the following query is the correct one for the rule 3? SELECT * FROM EMPLOYEE ORDER BY EMPNAME FOR XML ELEMENTS ROOT('ROOT') SELECT * FROM EMPLOYEE ORDER BY EMPNAME FOR XML RAW('ROW!'),ELEMENTS ROOT('ROOT')

SELECT * FROM EMPLOYEE ORDER BY EMPNAME FOR XML RAW,ELEMENTS ROOT('ROW') SELECT * FROM EMPLOYEE ORDER BY EMPNAME FOR XML RAW,ELEMENTS ROOT('ROOT') 209.

Sham has to convert the rows of the 'Employee' table to a xml file, adhering to the following rules : 1.The values in each row should be the property of the 'row' tag 2.Create another file in which the column name must be the tag name for each value 3.Root tag must have the name as 'ROOT' and each and every row must start with the tag name 'ROW' 4.Root tag must have a property specifying the xml Namespace Which clause helps in attaining the Xml namespace in the Root tag? XSINIL XMLDATA XMLSCHEMA XMLAUTO 210. 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? BINARY BASE16 BINARYBASE32 BINARY BASE64 BINARY BASE128 BINARY BASE64 is the only available encoding technique 211. Consider the following two statements: Staement 1: FOR XML RAW - does not support converting to XML file from a Join Query Statement 2: FOR XML AUTO - supports converting to XML file from a join Query

Which of the following is applicable for the above statements? 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 212. Which of the folllowng FOR XML clause helps in controling the hierarchy of the xml result set generated? 1 RAW AUTO EXPLICIT Y None of the listed options 213. Consider the following statement: With xmlnamespaces ( 'http://schemas.microsoft.com as act ) SELECT NAME,ADDRESS.query('//act:email') FROM PERSONAL_DETAILS FOR XML RAW('contactaddress'),ROOT('contactDetails) Query() method expects the pro-long part and body part when it is used along with 'WITH' statement . State TRUE or FALSE. TRUE FALSE Pro-long part is an optional one when used along with 'WITH' Statement. 214. Which of the following methods() decompose the xml into a logical table similar to OPENXML?

QUERY() VALUE() EXISTS()

NODES() 215. 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? 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 216. Consider the following scenario: Jothi is working on a Xml File, which contains a tag named Email and its value is 'DUMMY@DUMMY.COM'. She needs to find out the tag which contains the value as 'DUMMY@DUMMY.COM' and replace it with another value. Which of the following clause helps her in replacing the Value? Query() Exists() Values() Nodes() None of the listed options 217. Consider the following statement: SELECT * FROM SALES S JOIN PRODUCT P ON P.PRODUCT_ID=S.PRODUCT_ID

JOIN PURCHASE PU ON PU.PRODUCT_ID=P.PRODUCT_ID FOR XML RAW('Child'),ELEMENTS What is the outcome of the above statement? 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 218. Consider the following statement: SELECT * FROM SALES JOIN PURCHASE on PURCHASE.ID=SALES.ID FOR XML AUTO('ROW'),ELEMENTS What will be the outcome of the above statement? 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 219. Consider the following statement: SELECT * FROM SALES ORDER BY PRODUCT FOR XML RAW('ROW'),Elements XSINIL, ROOT('ROOT'),xmldata Which of the following gives the error in the above statement?

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

220. Consider the following table:

SALES ID 1 5

Contents table Chair

Here is the XML result from a Query. <ROOT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <CHILD> <id>1</id> <contents>table</contents> </CHILD> <CHILD> <id>5</id> <contents>chair</contents> </CHILD> </ROOT> Identify the Query which gave the above Result? SELECT * FROM SALES ORDER BY ID FOR XML RAW('CHILD'),Elements XSINIL, ROOT('ROOT') SELECT * FROM SALES ORDER BY ID FOR XML RAW('CHILD'),Elements, ROOT('ROOT') SELECT * FROM SALES ORDER BY ID FOR XML RAW('CHILD'), XSINIL, ROOT('ROOT')

SELECT * FROM SALES ORDER BY ID FOR XML RAW('CHILD'),Elements XSINIL -----------------------

221. Consider the following statement: SELECT * FROM SALES JOIN PURCHASE on PURCHASE.ID=SALES.ID FOR XML RAW('CHILD'),Elements XSINIL, ROOT('ROOT'),XMLSCHEMA Which of the following is applicable for the above query? a. The query returns a XML result set with the xml namespace as the property of the Root node only b. The query returns a xml result set in a xml schematic way c. The query gets executed and returns a result set which is not a XML format d. Error in the above statement 222. Consider the following statement: 1.SELECT TOP 1 ID,CONTENTS FROM SALES 2.JOIN 3.PURCHASE on PURCHASE.ID=SALES.ID 4.FOR XML RAW('CHILD'),Elements XSINIL, ROOT('ROOT'),XMLSCHEMA 5.BINARY 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? a. BASE32 b. BASE64 c. ENCODE32 d. ENCODE64 223. Consider the following item table and the statement: ITEM ID 1 2 CONTENTS Table 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? a. <contentsTable contents="table" /> <contentsTable contents="chair" /> b. <contents contentstable="table" /> <contents contentstable="chair" /> c. <contentTable contents="table" /> <contentTable contents="chair" /> d. <contentsTable content="table" /> <contentsTable content="chair" /> 224. Compare the following two statements: 1.SELECT * FROM ITEM FOR 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. a. Both the Queries will return the same result because 'PATH' clause is Element centric by default b. Both the Queries will return the same result because 'PATH' clause is attribute centric by default c. Both the Queries will NOT return the same result because 'PATH' clause is Element centric by default d. Both the Queries will NOT return the same result because 'PATH' clause is attribute centric by default 225. Consider the following statement: SELECT * FROM ITEM FOR XML PATH('PRODUCT'),XSINIL,ROOT('PRODUCTITEM') What is the outcome of the above statement? a. Returns a xml result set with ROW tag name as PRODUCTITEM b. Returns a xml result set with ROOT tag name as PRODUCTITEM c. Returns a xml result set with ROW tag name as PRODUCT and ROOT tag name as PRODUCTITEM d. Error in the above statement

e. XSINIL will not support if no ELEMENTS is used 226. Which of the following helps in taking a Column 'CONTENTS' value as a inner string in between the PRODUCTITEMS tag in FOR XML ? a. SELECT ID, CONTENTS 'string()' FROM ITEM FOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT') b. SELECT ID,CONTENTS 'innerstring()' FROM ITEM FOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT') c. SELECT ID,CONTENTS 'text()' FROM ITEM FOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT') d. Error in the above statement 227. Consider the following ITEM table and the statement: ID 1 2 CONTENTS Table Chair

SELECT CONTENTS 'processing-instruction(CONT)', (select ID 'data()'from item for xml path('')) 'work/worker/@id' FROM ITEM FOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT') What is the result of the above statement? a. <PRODUCT> <PRODUCTITEMS> <?CONT table?> <work> <worker id="1 2 0" /> </work> </PRODUCTITEMS> <PRODUCTITEMS> <?CONT chair?> <work> <worker id="1 2 0" /> </work> </PRODUCTITEMS> </PRODUCT> b. <PRODUCT> <PRODUCTITEMS> <?CONT table?> <work> <worker id="1 2 0" /> </work>

<?CONT chair?> <work> <worker id="1 2 0" /> </work> </PRODUCTITEMS> </PRODUCT> c. <PRODUCT> <PRODUCTITEMS> <work> <worker id="1 2 0" /> </work> </PRODUCTITEMS> <PRODUCTITEMS> <work> <worker id="1 2 0" /> </work> </PRODUCTITEMS> </PRODUCT> d. <PRODUCT> <PRODUCTITEMS> <?CONT table?> <worker id="1 2 0" /> </PRODUCTITEMS> <PRODUCTITEMS> <?CONT chair?> <worker id="1 2 0" /> </PRODUCTITEMS> </PRODUCT> 228. Which of the following statement helps in taking a Column 'CONTENTS' value as a Comment which is prefixed with 'Comments:' in FOR XML ? a. SELECT ID, 'Comments: ' + contents 'text()' FROM ITEM FOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT') b. SELECT ID, 'Comments: ' + contents 'comment()' FROM ITEM FOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT') c. SELECT ID, contents 'comment()' + ' Comments :' FROM ITEM FOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT') d. SELECT ID, contents as 'comment()' FROM ITEM FOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT') 229. 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? a. text() b. comment() c. processing-instruction() d. Data() 230. 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'? a. SELECT ID, contents 'tagname/@contents' FROM ITEM FOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT') b. SELECT ID, contents as 'tagname/@contents' FROM ITEM FOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT') c. SELECT ID, contents 'tagname/contents' FROM ITEM FOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT')

d. None of the listed options 231. 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')>60000 4.ORDER BY XS:NAME(STRING($ADDRESS/NAME)) DESC RETURN <PIN>823456 </PIN> )AS RESULT FROM CONTACT_DETAILS WHERE emp_id=10 Which of the following iterator or clause is not supported in SQL Server of the above numbered statement? a. LET b. FOR c. WHERE d. ORDER BY 232. Which of the following is NOT supported in MODIFY() method? a. UPDATE BOOKS SET AUTHORXML.MODIFY(' INSERT <books>Sql server by Mr.SHAM</books> AFTER (subject/database/@books)[1]') b. UPDATE BOOKS SET AUTHORXML.MODIFY(' INSERT <books>Sql server by Mr.SHAM</books> BEFORE (subject/database/@books)[1]') c. UPDATE BOOKS SET AUTHORXML.MODIFY(' INSERT <books>Sql server by Mr.SHAM</books> NEXT (subject/database/@books)[1]') d. UPDATE BOOKS SET AUTHORXML.MODIFY(' INSERT <books>Sql server by Mr.SHAM</books> INTO (subject/database/@books)[1]') 233. 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? a. Statement 1 is True, and Statement 2 is False

b. Statement 1 is False, and Statement 2 is True c. Both the Statements are True d. Both the Statements are False 234. Consider the following two statements regarding Query compilation and optimization: Statement 1: While Identifying the Join clause, query optimizer treats INNER JOIN as two different tables Statement 2: While Identifying the Join clause, query optimizer treats SELF JOIN as a single table Which of the following is applicable for the above statements? a. Statement 1 is True, and Statement 2 is False b. Statement 1 is False, and Statement 2 is True c. Both the Statements are True d. Both the Statements are False 235. 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? a. Step1 is valid, and Step2 is invalid b. Step1 is valid, and Step2 is invalid c. Both the Steps are valid d. Both the Steps are invalid 236. 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. a. TRUE

b. FALSE 237. How does Snapshot isolation differ from Read committed snapshot isolation? a. It maintains a snapshot of the data for the duration of the transaction b. It maintains statement level snapshot of the data c. It takes an exclusive lock on the entire table d. It isolates the database from access to other users e. None of the listed options 238. How many isolation levels can be active for a user at any point of time? a. 1 b. 2 c. Unlimited d. 1024 e. None of the listed options 239. If the same query or stored procedure is executed repeatedly, SQL server may not generate execution plan each time. State True or False. a. TRUE b. FALSE 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. 240. For which of the following situation SQL server may determine that an execution plan needs to be recompiled? a. Modifications to table or view referenced by query b. Lot of changes to key data c. Updates made to statistics used by the execution plan d. All of the listed options 241. Which of the following SELECT statement will execute the fastest? a. SELECT column1 from table1 WHERE column1 = 123;

b. SELECT column1 from table1 WHERE column1 <> 123; c. SELECT column1 from table1 WHERE column1 = @value1 d. SELECT column1 from table1 242. Consider the following sequence of operations from two users : User 1 SET TRANSACTION ISOLATION LEVEL SNAPSHOT go begin tran select * from book go Id Title -------2 Catch-22 3 Roses in December User 2 BEGIN TRAN update book set Title = Roses in December Edition 2 where id = 3 go User 1 update book set Title = My Experiments with Truth where id = 3 go What will be the outcome? a. User2's update will be overwritten by user1's update b. User 1 will get an update error due to Snapshot isolation c. User 2 will get an update error due to snapshot isolation d. Both the updates will be successful 243. Consider the following T-SQL statement : SELECT * FROM EMP_DETAILS INNER JOIN EMP_SALARYDETAILS ON EMP_DETAILS.EMP_ID=EMP_SALARYDETAILS.EMPID WHERE EMPID=1001 OR EMPID =1002 Identify the order of optimization of the following clauses

a.INNER JOIN b.WHERE c.OR a. a,b,c b. a,c,b c. b,c,a d. b,a,c 244. You are creating a procedure that will update two tables within a transaction. The code looks similar to the following: 1 BEGIN TRANSACTION 2 3 BEGIN TRY 4 UPDATE . . . 5 6 END TRY 7 8 BEGIN CATCH 9 IF . . . 10 11 END CATCH 12 Give the line number, where the ROLLBACK statement would normally be placed? a. 2 b. 5 c. 7 d. 10 245. You are creating a procedure that will update two tables within a transaction. The code looks similar to the following: 1 BEGIN TRANSACTION 2 3 BEGIN TRY 4 UPDATE . . . 5 6 END TRY 7 8 BEGIN CATCH 9 IF . . . 10

11 END CATCH 12 Give the line number, where the COMMIT statement would normally be placed? a. 5 b. 7 c. 10 d. 12 246.Consider the following stored procedure: 1 begin tran 2 update account set balance = balance - 1000 where account_number = 123 3 if @@error != 0 4 begin 5 rollback tran 6 return 7 end 8 update account set balance = balance + 1000 where account_number = 456 9 if @@error != 0 10 begin 11 rollback tran 12 return 13 end 14 commit tran If error code in line 9 is 12, what will be the outcome? a. The entire transaction is rolled back b. Update to 456 is rolled back but update to 123 is committed c. Both the updates are comitted d. Update to 123 is rolled back but update to 456 is committed 247. Consider the following stored procedure 1 begin tran add_book 2 insert book (id, name) values (2, SQL for dummies) 3 if @@error = 50000 4 begin 5 rollback tran add_book 6 return 7 end 8 save tran keep_the_first 09 insert book (id, name) values (3, 20 immutable laws of leadership) 10 if @@error = 50000 11 begin 12 rollback tran keep_the_first

13 end 14 commit tran If the error code returned by line 10 is 50000, what will be the outcome? a. Book id's 2 and 3 are inserted successfully b. Book id 2 is inserted but 3 is not inserted c. Book id 3 is inserted but 2 is not inserted d. Neither of the books are inserted 248. Consider the following stored procedure 1 begin tran add_book 2 insert book (id, name) values (2, SQL for dummies) 3 if @@error = 50000 4 begin 5 rollback tran add_book 6 return 7 end 8 save tran keep_the_first 09 insert book (id, name) values (3, 20 immutable laws of leadership) 10 if @@error = 50000 11 begin 12 rollback tran keep_the_first 13 end 14 commit tran If the error code returned by line 3 is 50000, what will be the outcome? a. Book id's 2 and 3 are inserted successfully b. Book id 2 is inserted but 3 is not inserted c. Book id 3 is inserted but 2 is not inserted d. Neither of the books are inserted 249. 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? a. The procedure creation is successful and while executing, it will return a xml file with INDIA as root node and STATE as row node b. The procedure creation is successful and while executing, it will return a xml file with STATE as root node and INDIA as row node c. The procedure creation is successful and while executing, it will not return a xml file due to run-time error d. The procedure creation fails due to compilation error e. Compilation fails because passing a variable is not possible in ROOT clause 250. Consider the following statement: DECLARE @XMLVAR XML SET @XMLVAR=' <INDIA> <STATES> <STATE SNO="1" SNAME="TN" /> </STATES> <STATES> <STATE SNO="2" SNAME="AP" /> </STATES> <STATES> <STATE SNO="3" SNAME="UP" /> </STATES> </INDIA>' SELECT XMLTABLE.XMLCOLUMN.query('SNAME') AS node, XMLTABLE.XMLCOLUMN.VALUE('STATE[1]/@SNO','CHAR(1)') AS STATE_CODE FROM @XMLVAR.nodes('/INDIA/STATES') AS XMLTABLE(xmlcolumn) What is the result of the above statement? a. Query will return a result set with SNO as STATE_CODE and SNAME as node

b. Query will return a result set with SNO as node and SNAME as STATE_CODE c. Select statement is not valid d. None of the listed options e. Value function is not supported in dynamic table

You might also like