Upload
manoj-kumar
View
262
Download
2
Tags:
Embed Size (px)
DESCRIPTION
sql
Citation preview
1. It is mandatory to define at least one secondary data file for a database.State True or False. Ans. False
2. 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
3. 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 limitWhich 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 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 tableStatement 2: An user can execute the stored procedure and inherits the rights on the referenced table from the owner within the context of the stored procedure
Which of the following is applicable for the above?
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
FETCH SECONDB. 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 USE AdventureWorks02 GO03 DECLARE contact_cursor CURSOR FOR04 SELECT LastName FROM Person.Contact05 WHERE LastName LIKE 'B%'06 ORDER BY LastName07 OPEN contact_cursor08 FETCH NEXT FROM contact_cursor09 WHILE @@FETCH_STATUS = 010 BEGIN11 ---- Missing Line 12 END13 ---- Missing Line14 ---- Missing Line
Which of the following lines of code can be correctly fitted into the missing lines?(Choose 3)
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 subqueryb. Correlated subqueryc. Plain Subqueryd. Join Subquery
42. Which of the following is NOT used to combine data from multiple tables?
a. Unionb. Subqueryc. Joind. Role
43. Which of the following helps us to create and populate a new table with the data of an existing table?
a. SELECT INTOb. UNIONc. SUBQUERYd. JOIN
44. A set of statements is to be executed 10 times.
Which of the following constructs can we use for this task?
a. IF..ELSEb. WHILEc. CASEd. 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. Integrityb. Domain Integrityc. User Defined Integrityd. Entity Integrity
46. Which of the following type of integrity maintains the relationship between tables in a database?
a. Referential Integrityb. Domain Integrityc. User Defined Integrityd. Entity Integrity
47. Which of the following type of integrity ensures each record in a table is Unique?
a. Data Integrityb. Domain Integrityc. User Defined Integrityd. 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 possibleb. Further normalize the tablec. 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 optionsd. 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 parenthesisb. A subquery must be put in the right hand side of the comparison
operatorc. A subquery cannot contain a ORDER-BY claused. A query should not contain more than one sub-query----Y
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. Insert
b. Changing Column Namec. Increasing column lengthd. Modify datatypee. Decreasing column lengthf. 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, 1965c. It retrieves information of employees who have been hired after
february 1, 2007d. 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. SCHEMABINDING clauseb. FOR CREATION OF INDEX clausec. UNIQUE clause in the CREATE SCHEMA lined. 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. Adds files with new namesb. Adds files to foldersc. Adds files to filegroupsd. 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. Modifies the name of the Employee database log fileb. Alters the Employee database structurec. Moves the log file of the Employee database to the root of the C:
drived. 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. It is an error and invalid data typeb. It could be an user defined data typec. It is a valid basic data type supportedd. 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_p1b. Creates Customers_p1 table in file group custPS1c. Creates Customers_p1 table in partition scheme custPS1 and
column order_dt is used for partitioningd. 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,cityCREATE TRIGGER tr_au_upd ON authorsFOR INSERT, UPDATE ASIF 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,cityCREATE TRIGGER tr_au_upd ON authorsFOR INSERT, UPDATE AS
IF UPDATE(city) BEGIN ROLLBACK TRAN END GOThe 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,cityCREATE TRIGGER tr_au_upd ON authorsFOR UPDATE ASIF UPDATE(city) BEGIN ROLLBACK TRAN END GOThe 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,cityCREATE TRIGGER tr_au_upd ON authors
INSTEAD OF UPDATE ASPRINT 'Trigger output row updated'GOThe following statements are executed on the authors table:INSERT authors(au_id, au_name)VALUES (1001, 'Rajeev')UPDATE authors SET au_name = 'Raghav' WHERE au_id = 1001GO SELECT au_id, au_name WHERE au_id =1001GOWhat 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,cityCREATE TRIGGER tr_au_upd ON authorsINSTEAD OF UPDATE ASIF @@ROWCOUNT = 0 RETURNUPDATE authors SET au_name = 'Raman' WHERE au_id = 1001GOThe following statements are executed on the authors table:INSERT authors(au_id, au_name)VALUES (1001, 'Rajeev')UPDATE authors SET au_name = 'Raghav' WHERE au_id = 1001GO SELECT au_id, au_name WHERE au_id =1001
GOWhat 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_auditON DATABASEFOR CREATE_TABLE, ALTER_TABLE, DROP_TABLEAS ROLLBACKGOThe following statement is isused on table 'titles' in the databaseALTER TABLE titles ADD new_col INT NULLALTER 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_auditON DATABASEFOR CREATE_INDEX, ALTER_TABLE, DROP_INDEXAS
DECLARE @EventData XML SET @EventData = EVENTDATA() SELECT @EventData.Query ('' data(/EVENT_INSTANCE/PostTime )'' ) GOThe 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, locationdeptid is the primary keyTable 'emp' holds information about employees like empid, name, deptid, dateofbirthdeptid is the foreign key referencing the primary key deptid of table dept.In case a department is closed, the department row needs to be deleted from 'dept' table. Since foreign key constraint exists, the department row cannot be deleted if there are any employees in that department.To overcome the above, an AFTER TRIGGER was created on the 'dept' table with code to delete the individual employee rows based on the deptid.Which of the following is the final outcome of issuing a DELETE statement for a deptid in the 'dept' table?
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' , 0What 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?
A 2
B 4
C 3
D 7
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_index3. sys.XML_indexes_ALL4. sys.XML_indexes_catalog
102. Which of the following fixed server roles can manage linked servers?1. processadmin2. setupadmin3. securityadmin 4. serveradmin
103. You need to perform these tasks:01 Create and assign a MANAGER role to Blake and Clark02 Grant CREATE TABLE and CREATE VIEW privileges to Blake and Clark
Which of the following set of SQL statements achieves the desired results?1. CREATE ROLE managerGRANT create table, create viewTO manager;GRANT manager TO BLACK, CLARK;2. CREATE ROLE managerGRANT create table, create voewTO manager;GRANT manager ROLE TO BLACK, CLARK;3. GRANT manager ROLE TO BLACK, CLARK;GRANT create table, create voewTO 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 202. CREATE SEQUENCE SE START WITH 30 ADD BY 203. CREATE SEQUENCE SE START WITH 30 INCREMENT BY 204. 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 DateTimeEmpNum and ProjNum form the composite primary key and we want to
define aPrimary Key constraint with those columns.Choose a valid statement for the above scenario.1. EmpNum column or ProjNum column can not have duplicate values2. EmpNum and ProjNum columns can not be nullable3. More than one column is not allowed for a primary key constraint4. 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 optionWhat happens when a department is deleted in the DEPARTMENT table?1. All records in EMPLOYEE table belonging to that department are deleted2. 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 NULL4. 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 tableWhat 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 table2. No update occurs and no error is given3. An error is returned as data integrity is violated4.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 table2. The DEPARTMENT record is deleted and the Dept_id column in EMPLOYEE tabel is set to null values3. The DEPARTMENT record is deleted and the Dept_id column in EMPLOYEE tabel is set to spaces4. An error is returned as data integrity is violated109. Consider the following table (ORDERS)
OrderNum Amount ODATE CustNum3001 250 03-oct-94 10073003 200 03-oct-94 10013002 300 03-oct-94 10043005 200 04-oct-94 10013004 200 04-oct-94 1003
What will be the Row_Number for CustNum of 1007 in the following query?select CustNum, sum(Amount),
ROW_NUMBER () OVER (order by sum(Amount) DESC) as Row_Numberfrom ORDERS group by CustNumorder by sum(Amount) desc1.12.13.34.4110. Consider the following table (ORDERS)
OrderNum Amount ODATE CustNum3001 300 03-oct-94 10073003 200 03-oct-94 10013002 300 03-oct-94 10043005 200 04-oct-94 10013004 200 04-oct-94 1003
What will be the Rank for CustNum of 1003 in the following query?select CustNum, sum(Amount),RANK () OVER (order by sum(Amount) DESC) as Rankfrom ORDERS group by CustNumorder by sum(Amount) desc1.12.23.34.4111. Consider the following table (ORDERS)
OrderNum Amount ODATE CustNum3001 300 03-oct-94 1007
3003 200 03-oct-94 10013002 300 03-oct-94 10043005 200 04-oct-94 10013004 200 04-oct-94 1003
What will be the Dense_Rank for CustNum of 1003 in the following query?select CustNum, sum(Amount),DENSE_RANK () OVER (order by sum(Amount) DESC) as Dense_Rankfrom ORDERS group by CustNumorder by sum(Amount) desc1.12.23.34.4112. Consider a table 'employees' and a stored procedure 'sp_process'
The following statements are executed:
sp_processSELECT * from employees
What is the outcome of above execution?1. The SELECT statement does not execute but stored procedure sp_process executes2. The SELECT statement executes but stored procedure sp_process does not execute3. 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 intAS----processing done hereRETURN
The above PROC is executed twice as below:1) EXEC myproc @parm1 = 4, 5, 62) EXEC myproc 4, @parm2 = 5, @parm3 = 6
What is the outcome of executing as above?1. With 1) The PROC runs successfully using the parameter values suppliedWith 2) The PROC runs successfully using the parameter values supplied2. With 1) The PROC give error as the parameters are not supplied properlyWith 2) The PROC runs successfully using the parameter values supplied3. With 1) The PROC runs successfully using the parameter values suppliedWith 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 properlyWith 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 gosp_configure 'clr enabled', 1goreconfigurego 2. ALTER DATABASE <database> SET TRUSTWORTHY ONgosp_configure 'clr enabled', 1go3. ALTER DATABASE <database> SET TRUSTWORTHY ONgosp_configure 'clr'goreconfigurego 4. ALTER DATABASE <database> SET TRUSTWORTHY ONsp_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 procedures2. Use Nested stored procedures3. Use extended stored procedures4. Drop the stored procedures that are not in use
116. Consider the following stored procedures:CREATE proc main_procASexec sub_proc1exec sub_proc2returngo
CREATE proc sub_proc1ASexec sub_proc2go
CREATE proc sub_proc2ASreturn
How many times will the proc sub_proc2 get executed upon invoking EXEC main_proc?1. 2 times2. 16 times3. 32 times4. 31 times5. 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; ENDELSE BEGIN -- Return 0 to the calling program to indicate success. PRINT N'The job candidate has been deleted.'; RETURN 0; END;
GO
Which of the following is the correct statement that can be fitted in the ---missing line -----?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_proc2. Gives execution error3. 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 employeessp_process
What is the outcome of the above execution?1. The SELECT statement does not execute but stored procedure sp_process executes2. The SELECT statement executes but stored procedure sp_process does not execute3. Both SELECT and stored procedure sp_process fail to execute4. Both SELECT and stored procedure sp_process execute successfully120. Consider a table 'employees' and a stored procedure 'sp_process'The following statements are executed:SELECT * from employeesEXEC sp_process
What is the outcome of the above execution?1. The SELECT statement does not execute but stored procedure sp_process executes2. The SELECT statement executes but stored procedure sp_process does not execute3. Both SELECT and stored procedure sp_process fail to execute4. Both SELECT and stored procedure sp_process execute successfully
121. Consider the following stored procedure creation:
CREATE proc sp_create_staffASEXEC sp_use_jobs
It so happens that the user missed creating the stored procedure sp_use_jobs in the database.
What will be the outcome of the create procedure sp_create_staff as above?
a. The sp_create_staff procedure is not created due to severe errorb. The sp_create_staff procedure is created with a warning errorc. The sp_create_staff procedure is created without any kind of errorsd. The sp_use_jobs procedure is automatically created before sp_create_staff procedure is createde. 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 = 300AS----processing done hereRETURN
The above PROC is executed twice as below:1) EXEC myproc 2) EXEC myproc @parm1 = DEFAULT, @parm2 = 5, @parm3 = 6
What are the value of parameters passed to myproc in both the cases?
a. With 1) parm1 = 0, parm2 = 0, parm3 = 0With 2) parm1 = 100, parm2 = 5, parm3 = 6b. With 1) Gives error due to incorrect parameter passingWith 2) parm1 = 100, parm2 = 5, parm3 = 6c. With 1) parm1 = 100, parm2 = 200, parm3 = 300With 2) parm1 = 100, parm2 = 5, parm3 = 6d. With 1) parm1 = 100, parm2 = 200, parm3 = 300
With 2) parm1 = 0, parm2 = 5, parm3 = 6e. With 1) parm1 = 100, parm2 = 200, parm3 = 300With 2) Gives error due to invalid parameter passingf. 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 ASSELECT * FROM dbo.titles where advance between @low and @highRETURN
Which of the following are valid ways of executing the above proc in case recompilation of query plan is required before executing?(Choose 2)
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 avg3GO
Assume that averagebookprice is a user defined scalar function that returns a value of 100.09 for 'computers' which of the following is a correct statement?
a. avg1 will be 100.09, avg2 will be 100 and avg3 will be 100.10b. avg1 will be 100.09, avg2 will be 100.09 and avg3 will be 100.09c. avg1 will be 100, avg2 will be 100.09 and avg3 will be 100.10d. avg1 will be 100.10, avg2 will be 100 and avg3 will be 100.09e. avg1 will be 100, avg2 will be 100 and avg3 will be 100f. 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 100b. avg1 will be displayed as 100.09c. There will be execution error in the statementsd. avg1 will be displayed as 100.10e. since the schema name is missing, there will be execution errorf. 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.0RETURNS @tableAS Insert @table SELECT type, avg(isnull(price, 0)) as avg_price FROM titles GROUP BY type HAVING avg(isnull(price, 0) > @price RETURN
Which of the following explains the missing statements to be included in above?(Choose 2)a. Include BEGIN….END as wrappers around the statements the function contains.b. Include the clause 'MULTI-STATEMENT TABLE' in the CREATE statementc. 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.0RETURNS @table table(type varchar(12) null, avg_price money null)AS
BEGIN Iinsert @table SELECT type, avg(isnull(price, 0)) as avg_price FROM titles GROUP BY type HAVING avg(isnull(price, 0) > @price RETURNEND
Which of the following example is correct to invoke the above function?a. Select * from multi-statement table function averagepricebytype(15)b. Select * from averagepricebytype(15)c. Select * from averagepricebytype(15) using multi-statement table functiond. 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.0RETURNS @table table(type varchar(12) null, avg_price money null)with schemabindingAS BEGIN Iinsert @table SELECT type, avg(isnull(price, 0)) as avg_price FROM titles GROUP BY type HAVING avg(isnull(price, 0) > @price RETURNEND
The following command is issued on the table 'titles' that is used in the function above:ALTER table titles alter column price smallmoney null
Which of the following happens upon executing the ALTER command?
a. The ALTER command fails b. The price column is changedc. The price column is changed only if no user is using the averagepricebytype function when the ALTER command is issuede. None of the listed optionsd. cannot alter when the column is used in a function Ans : a
129.Consider the following Function:
CREATE FUNCTION striptime(@datetimeval datetime)
RETURNS datetimeWITH RETURNS NULL ON NULL INPUTAS BEGIN DECLARE @dateval datetime SELECT @dateval = convert(char(10), isnull@datetimeval), getdate()), 110) RETURN @datevalEND
Which of the following happens when the above function is invoked with NULL input?
a. The FUNCTION body gets executed and NULL is returned as resultb. The FUNCTION body does not get executed and the value of NULL is returned
c. The FUNCTION returns error if input is NULLe. None of the listed options
Ans : b
130.Consider the following function creation:
CREATE FUNCTION dbo.getonlydate()RETURNS datetimeasBEGIN DECLARE @date datetime SET @date = dbo.striptime(getdate()) RETURN @dateEND
Assume 'striptime' is another function already created.
Which of the following statement is correct for the above create function?
a. The CREATE function is not valid and gives errorb. The CREATE function is valid but will give execution error that striptime is not foundc. The CREATE function is valid and will not give any execution error on existence of striptime function.d. None of the listed optionse. one function can call another - nesting
ans : c
131.Consider the following function creation:
CREATE FUNCTION dbo.getonlydate()RETURNS datetimeasBEGIN DECLARE @date datetime SET @date = getdate() RETURN @dateEND
Which of the following happens due to the use of non-deterministic function getdate() in the above UDF?
a. The CREATE function is not valid and gives errorb.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 optionse. getdate() valid built in non-deterministic function to be usedAns : c
132. Consider the following function creation:
CREATE FUNCTION dbo.getonlydate()RETURNS datetimeasBEGIN DECLARE @date datetime, @randomdata int SET @date = getdate() SET @randomdata = rand() RETURN @date END
Which of the following happens due to the use of non-deterministic functions getdate() and rand() in the above UDF?
a. The CREATE function is not valid and gives errorb. 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 optionse.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 functionb. Create fails because it is an invalid type of table valued functionc. Create fails because it is an invalid type of scalar functiond. None of the listed optionse. 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 RETURNEND
Which of the following statement is correct for the above statements?
a.The CREATE fails but ALTER succeedsb.The CREATE succeeds but ALTER failsc. Both CREATE and ALTER failsd. CREATE and ALTER go through successfullye.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 succeedsb.CREATE and ALTER go through successfullyc. can modify inline function stmtsd. Both CREATE and ALTER failse.CREATE and ALTER go through successfully
Ans : b 136. Consider the creation of following stored procedure:
CREATE proc check_user_whoWITH EXECUTE AS 'Sunil'ASSELECT user_name() as 'User name applicable'GO
The following statements are executed:
SELECT user_name() as 'User name applicable'EXEC check_user_who
What is the result of SELECT in sequence when the above statements are executed?a.User name applicable - dboUser name applicable - Sunilb. User name applicable - dboUser name applicable - dboc. User name applicable - SunilUser name applicable - dbod.User name applicable - SunilUser name applicable - Sunile. execte as overrides the user name to sunil
137.Consider the following stored procedure creation:
CREATE proc sp_check_authorsASSELECT au_id, au_name, au_last_title FROM authors WHERE au_id > 1001GO
It so happens that the authors table is dropped and no longer exists in the database.What will be the outcome of the create procedure sp_check_authors as above?a. The sp_check_authors procedure is not created due to severe errorb. The sp_check_authors procedure is created with a warning errorc. The sp_check_authors procedure is created without any kind of errorsd. The authors table is automatically created before sp_check_authors procedure is createde. delayed resolution is permitted, no error during create for table objects
Ans : c
138. Consider the following stored procedure creation:
CREATE proc sp_check_authorsASSELECT au_id, au_name, au_last_title FROM authors WHERE au_id > 1001GO
It so happens that the authors table is dropped and no longer exists in the database.
Now the following statement is issued EXEC sp_check_authorsGO
What will be the outcome of the above create and execution statements?a. Both Create and execution failsb. Create fails but execution goes through without errorsc. Both Create and execution goes through without errorsd. Create is successful but execution gives errore. 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_authorsAS 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_authorsGO
SELECT definition FROM sys.sql_modules WHERE object_id = object_id('sp_check_authors')GO
SELECT object_definition (object_id('dbo.sp_check_authors'))GO
What will be the outcome of the above statements issued?
a. The source code of the stored procedure sp_check_authors is displayed 2 timesb. The source code of the stored procedure sp_check_authors is displayed oncec. The source code of the stored procedure sp_check_authors is displayed onced. The source code of the stored procedure sp_check_authors is displayed 3 timese. 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)asBEGIN TRYINSERT INTO comp1.dbo.itemmaster
(item_id, item_name)VALUES(@item_id, @item_name)print ‘New Item added’END TRYBEGIN CATCHexec error_handlerRETURN -101END CATCHRETURN 0
What is the return code if the following statement is executed?
EXEC insert_items ‘ABCDEFGH’, ‘Gear Assembly’
a. 0b.-101c. NULLd. -1e. 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 OUTPUTASSELECT @ytd_sales = ytd_sales FROM titles where title = @titleRETURNThe 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_todayWhat 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 truthGone with the windCREATE PROC ytd_sales2 @title varchar(80)ASIF NOT EXISTS (SELECT * FROM titles WHERE title = @title) RETURN -111SELECT ytd_sales from titles where title = @title RETURN GOThe above PROC is executed as follows:DECLARE @status INT EXEC @status = ytd_sales2 'Life without fear'IF @status = -111 PRINT 'No book with that name found'GOEXEC @status = ytd_sales2 'Undefeated'GOEXEC @status = ytd_sales2 'Gone with the wind'IF @status = -111 PRINT 'No book with that name found'GO
How many times the message 'No book with that name found'' will be displayed for the above scenario?
a) once
b) twice
c) none
d) thrice
144. Consider the following statements:
CREATE PROC pub_testASSELECT pub_id, pub_name, city, statecdinto ##tempfrom publisherswhere statecd in ('MH', 'AP', 'TN')
SELECT pub_id, pub_name, city, statecdinto #tempfrom publisherswhere statecd in ('MH', 'AP', 'TN')GO
The following sequence of execution statements are made:
EXEC pub_testGOSELECT * from ##temp -----1SELECT * from #temp -----2
EXEC pub_testGOSELECT * from ##temp ------3
What is the correct sequence of outcome on executing the SELECT statements marked 1,2 3 as above?
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_testASSELECT pub_id, pub_name, city, statecdinto ##tempfrom publisherswhere statecd in ('MH', 'AP', 'TN')
SELECT pub_id, pub_name, city, statecdinto #tempfrom publisherswhere statecd in ('MH', 'AP', 'TN')GO
The following sequence of execution statements are made:
EXEC pub_testGO
SELECT * from ##temp ------- 1SELECT * from #temp ------- 2DROP table ##tempEXEC pub_testGOSELECT * from ##temp -------- 3
What is the correct sequence of outcome on executing the SELECT statements marked 1,2,3 as above?
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)ASEXEC('select title_id, title = substring(title, 1, 40), type, price FROM titles where type in ('+ @typelist + ') order by type, title_id')GO
set quoted_identifier off
The stored procedure is executed as below:EXEC find_books_by_type "'business', 'mod_cook', 'trad_cook'"GO
Which of the following are correct statements for the above scenario?(Choose 2)
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 = @valueGOCREATE PROC get_titles_data_by_advance(@flag tinyint, @value money)AS select * from titles where advance = @valueGOCREATE PROC get_titles_data(@flag tinyint, @value money)ASif @flag = 1 exec get_titles_data_by_price @value else exec get_titles_data_by_advance @value
Which of the following stored procedure is functionally equivalent to the above set of stored procedures?
a) CREATE PROC get_titles_data_by_price(@flag tinyint, @value money)AS exec get_titles_data @valueGOCREATE PROC get_titles_data_by_advance(@flag tinyint, @value money)AS exec get_titles_data @valueGOCREATE PROC get_titles_data(@flag tinyint, @value money)ASif @flag = 1 exec get_titles_data_by_price @valueelse exec get_titles_data_by_advance @value
b) CREATE PROC get_titles_data(@flag tinyint, @value money)ASSelect * from titles where price = @value or advance = @value
c) CREATE PROC get_titles_data(@flag tinyint, @value money)ASif @flag = 1 select * from titles where price = @valueelse 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 intAS----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 = 0With 2) Gives error - Procedure 'myproc' expects parameter '@parm2' which was not supplied
d) With 1) parameters passed: parm1 = 0, parm2 = 0, parm3 = 0With 2) parameters passed: parm1 = 6, parm2 = 0, parm3 = 0
149. Consider the following stored procedures:
CREATE proc main_procASexec sub_proc1exec sub_proc3exec sub_proc2returngo
CREATE proc sub_proc1ASexec sub_proc2
go
CREATE proc sub_proc2ASexec proc sub_proc3return
CREATE proc sub_proc3ASexec 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_name…table
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 recordsid title--- ------2 Catch-223 Roses in December4 My experiments with Truth
Assume a default isolation level of 'READ COMMITTED' for the following commands. User1 has issued the following commandsBEGIN TRANSELECT title FROM book where id = 2;User2 has now issued the following commandsSELECT title FROM book where id = 2;What will be the outcome?
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 recordsid title--- ------2 Catch-223 Roses in December4 My experiments with TruthAssume a default isolation level of 'READ COMMITTED' for the following commands. User1 has issued the following commandsBEGIN TRANSELECT title FROM book WITH (UPDLOCK) where id = 2;User2 has now issued the following commandsSELECT title FROM book where id = 2;What will be the outcome?
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 recordsid title--- ------2 Catch-223 Roses in December4 My experiments with TruthAssume a default isolation level of 'READ COMMITTED' for the following commands. User1 has issued the following commandsBEGIN TRANSELECT title FROM book WITH (UPDLOCK) where id = 2;User2 has now issued the following commandsSELECT title FROM book WITH (UPDLOCK) where id = 2;What will be the outcome?
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 recordsid title--- ------2 Catch-223 Roses in December4 My experiments with TruthAssume a default isolation level of 'READ COMMITTED' for the following commands.
User1 has issued the following commandsBEGIN TRANSELECT title FROM book WITH (UPDLOCK) where id = 2;User2 has now issued the following commandsSELECT title FROM book WITH (UPDLOCK) where id = 3;What will be the outcome?
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 recordsid title--- ------2 Catch-223 Roses in December4 My experiments with TruthAssume a default isolation level of 'READ COMMITTED' for the following commands. User1 has issued the following commandsBEGIN TRANSELECT title FROM book where id = 2;User2 has now issued the following commandsUPDATE book SET title = 'Roses in December, Second edition' WHERE id = 2What 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 recordsid title--- ------2 Catch-223 Roses in December4 My experiments with TruthAssume a default isolation level of 'READ COMMITTED' for the following commands. User1 has issued the following commandsBEGIN TRANUPDATE book SET title = 'Roses in December, Second edition' WHERE id = 2User2 has now issued the following commandsSELECT title FROM book WHERE id = 2What 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 recordsid title--- ------2 Catch-223 Roses in December
4 My experiments with TruthAssume a default isolation level of 'READ COMMITTED' for the following commands. User1 has issued the following commandsBEGIN TRANSELECT title FROM book WITH (UPDLOCK, HOLDLOCK) WHERE id = 2User2 has now issued the following commandsSELECT title FROM book WHERE id = 2What 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 recordsid title--- ------2 Catch-223 Roses in December4 My experiments with TruthAssume a default isolation level of 'READ COMMITTED' for the following commands. User1 has issued the following commandsBEGIN TRANSELECT title FROM book WITH (UPDLOCK, HOLDLOCK)User2 has now issued the following commandsINSERT INTO book VALUES(5, 'Harry Potter and the Half-blood
Prince')What will be the outcome?
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 recordsid title--- ------2 Catch-223 Roses in December4 My experiments with TruthAssume a default isolation level of 'READ COMMITTED' for the following commands. User1 has issued the following commandsBEGIN TRANSELECT title FROM book WITH (UPDLOCK, HOLDLOCK) WHERE title like '%experiments%'User2 has now issued the following commandsINSERT INTO book VALUES(6, 'Harry Potter and the Half-blood Prince')What will be the outcome?
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 deadlock173. Consider the following scenario:A Table 'book' has the following recordsid title--- ------2 Catch-223 Roses in December4 My experiments with TruthAssume a default isolation level of 'READ COMMITTED' for the following commands. User1 has issued the following commandsBEGIN TRANDELETE FROM book WHERE title like '%experiments%'User2 has now issued the following commandsINSERT INTO book VALUES(6, 'Harry Potter and the Half-blood Prince')What will be the outcome?
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 recordsid title--- ------2 Catch-223 Roses in December4 My experiments with Truth
Assume a Isolation level of 'READ_COMMITTED_SNAPSHOT' for
the following commands. User1 has issued the following commandsBEGIN TRANUPDATE book SET title = 'Roses in December, Second edition' WHERE id = 2User2 has now issued the following commandsSELECT title FROM book WHERE id = 2What 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 TRANDELETE FROM TABLE1BEGIN TRAN INSERT INTO TABLE2COMMITUPDATE TABLE3COMMITIf 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.nameFROM player p,player mWHERE m.manager_id=p.id;Statement 2:SELECT p.name,m.nameFROM player p,player mWHERE m.manager_id=p.id;Which of the following is applicable for the above statements?
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 ENDEND
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 ENDEND
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_oneWAITFOR TIME '02:00:22'BEGIN EXEC sp_process_total_twoENDSupposing 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
181 "Consider the following cursor processing:
DECLARE authors_cursor FORWARD_ONLY FORSELECT au_lname, au_fname FROM authorsORDER BY au_lname, au_fnameOPEN authors_cursorFETCH FIRST FROM authors_cursorFETCH RELATIVE 3 FROM authors_cursorFETCH RELATIVE -2 FROM authors_cursorCLOSE authors_cursorDEALLOCATE authors_cursor
(Assume that authors table has 200 author profiles)
What is the outcome of executing the above cursor statements?"
1 Three author profiles are retrieved from authors2 One author profile is retrieved from authors3 No author profiles are retrieved from authors4 Gives execution error cannot use relative, with
forward_only cursor
182 Consider the following cursor processing:
DECLARE authors_cursor SCROLL FORSELECT au_lname, au_fname FROM authorsORDER BY au_lname, au_fnameOPEN authors_cursorFETCH NEXT FROM authors_cursorFETCH ABSOLUTE 20 FROM authors_cursorFETCH RELATIVE 3 FROM authors_cursor
FETCH RELATIVE -7 FROM authors_cursorFETCH FIRST FROM authors_cursor CLOSE authors_cursorDEALLOCATE authors_cursor(Assume that authors table has 200 author profiles)
How many unique rows are retrieved upon executing the above cursor statements?"
1 Five2 Four3 Three4 Six5 None of the listed options6 Next and first retrive same rows
183 Consider the following cursor processing statements:
DECLARE Employee_Cursor CURSOR READ_ONLY FORSELECT LastName, FirstName, status FROM dbo.EmployeesWHERE LastName like 'B%'
OPEN Employee_CursorFETCH NEXT FROM Employee_Cursor PRINT @@FETCH_STATUSWHILE @@FETCH_STATUS = 0BEGIN FETCH NEXT FROM Employee_Cursor PRINT @@FETCH_STATUSEND
CLOSE Employee_CursorDEALLOCATE Employee_Cursor
(Assume that the Employees table has 500 rows of employee data)What is the value of @@FETCH_STATUS printed in the last print statement as per above?
1 02 13 -14 2
184 "Consider the following cursor processing statements:
DECLARE @cba CURSORDECLARE abc CURSOR GLOBAL SCROLL FOR SELECT * FROM authors SET @cba = abc OPEN abc FETCH NEXT FROM @cba FETCH NEXT FROM abc FETCH NEXT FROM @cba
CLOSE @cbaDEALLOCATE abc
In case the authors table had 100 author profiles, how many authors will get retrieved as per above processing?"
1 Two2 Three3 One4 None5 Gives error message both cursor and cursor variable
used interchangeably
185 Consider the following cursor processing statements:
DECLARE Employee_Cursor CURSOR FAST_FORWARD FORSELECT LastName, FirstName, status FROM dbo.EmployeesWHERE LastName like 'B%' FOR UPDATEOPEN Employee_CursorFETCH NEXT FROM Employee_CursorWHILE @@FETCH_STATUS = 0BEGIN DELETE Employees WHERE current of Employee_Cursor FETCH NEXT FROM Employee_Cursor END
CLOSE Employee_CursorDEALLOCATE Employee_Cursor(Assume that the Employees table has 500 rows of employee data)What is the outcome of the above cursor processing?"
1 All employees whose lastname starts with 'B' are deleted
2 The last employee with lastname starting with 'B' alone is deleted
3 The first employee with lastname starting with 'B' alone is deleted
4 Gives error message Cannot update/delete with fast_forward option
186 Consider the following statements:
WHILE (1=1)BEGIN WAITFOR TIME '01:00' EXEC sp_update_stats RAISERROR('Statistics updated for database',1,1) WITH LOGEND
What is the outcome of the above?"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
4 Gives error message while loop keeps it running, and waitfor 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_lnameFROM authorsWHERE state = 'UT'ORDER BY au_idOPEN authors_cursorIF @@CURSOR_ROWS = 0 ENDFETCH NEXT FROM authors_cursor IF @@FETCH_STATUS = -1 PRINT 'NO ROWS FOUND'ENDWHILE @@FETCH_STATUS = 0 BEGIN
PRINT 'ATLEAST ONE ROW FOUND ' FETCH NEXT FROM authors_cursor ENDENDCLOSE authors_cursorDEALLOCATE authors_cursor
What is the message that gets printed in case the authors table does not have any rows satisfying the given condition?"
1 Prints message 'NO ROWS FOUND' Y
2 Prints message 'ATLEAST ONE ROW FOUND'
3 Prints no message Y
4 Gives error message since cursor check does not do anything, message dispalyed for fetch status check
188 Consider the following cursor processing statements:
DECLARE @cba CURSORDECLARE abc CURSOR GLOBAL SCROLL FOR SELECT * FROM authors OPEN abc FETCH NEXT FROM @cba FETCH NEXT FROM abc FETCH NEXT FROM @cbaCLOSE @cbaDEALLOCATE abcIn case the authors table had 100 author profiles, how many authors will get retrieved as per above processing?"
1 Two2 Three3 One
4 None5 Gives error message Y Since cursor variable is not set
to cursor , error occurs
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' ENDFROM 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" Y
2 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 None of the listed options
190 Consider the following scenario:
A proc is created as follows:CREATE PROC cursor_proc @cursor CURSOR VARYING OUTPUTASDECLARE curs1 CURSOR GLOBAL FOR SELECT cast(title as varchar(30)) as title, pubdate from titlesset @cursor = curs1open curs1returngoNow the following statements are executed:DECLARE @curs CURSOR EXEC cursor_proc @cursor = @curs outputfetch curs1fetch @cursclose curs1deallocate curs1fetch @cursopen @cursgo
What is the outcome of the last fetch and open statements in above?"
1 Fetch and Open both fail 2 Fetch fails but open succeeds Y3 Fetch succeeds but open fails4 Fetch and open both succeed open succeeds
since not fully dealocated
191 Consider the following scenario:
A proc is created as follows:
CREATE PROC cursor_proc @cursor CURSOR VARYING OUTPUTASDECLARE curs1 CURSOR GLOBAL FOR SELECT cast(title as varchar(30)) as title, pubdate from titlesset @cursor = curs1open curs1returngo
Now the following statements are executed:DECLARE @curs CURSOR EXEC cursor_proc @cursor = @curs outputfetch curs1fetch @cursclose curs1deallocate curs1fetch @cursopen @cursfetch @cursclose @cursdeallocate @cursopen @cursgo
What is the outcome of the last fetch and open statements in the above statements?"
1 Fetch and Open both fail 2 Fetch fails but open succeeds3 Fetch succeeds but open fails Y4 Fetch and open both succeed since fully
deallocated at the end, cannot open after that
192 Consider the following scenario:
A proc is created as follows:
CREATE PROC cursor_proc @cursor CURSOR VARYING OUTPUTASDECLARE curs1 CURSOR GLOBAL FOR SELECT cast(title as varchar(30)) as title, pubdate from titlesset @cursor = curs1open curs1returngoNow the following statements are executed:DECLARE @curs CURSOR EXEC cursor_proc @cursor = @curs outputfetch curs1fetch @cursclose curs1deallocate curs1deallocate cursfetch @cursopen @cursgo
What is the outcome of the last fetch and open statements in the above statements?"
1 Fetch and Open both fail Y
2 Fetch fails but open succeeds
3 Fetch succeeds but open fails
4 Fetch and open both succeed since both references are deallocated, cannot fetch or open
193 Consider the following scenario:
A proc is created as follows:
CREATE PROC cursor_proc @cursor CURSOR VARYING OUTPUTASDECLARE curs1 CURSOR GLOBAL FOR SELECT cast(title as varchar(30)) as title, pubdate from titlesset @cursor = curs1open curs1returngoNow the following statements are executed:DECLARE @curs CURSOR EXEC cursor_proc @cursor = @curs outputfetch curs1fetch @cursclose curs1deallocate curs1fetch @cursopen @cursfetch @cursclose @cursopen @cursgo
What is the outcome of the last fetch and open statements in the above statements?"
1 Fetch and Open both fail 2 Fetch fails but open succeeds3 Fetch succeeds but open fails4 Fetch and open both succeed Y since not
deallocated, open works
194 Consider the following cursor processing:
DECLARE authors_cursor FAST_FORWARD FORSELECT au_lname, au_fname FROM authorsORDER BY au_lname, au_fnameOPEN authors_cursorFETCH NEXT FROM authors_cursorFETCH NEXT FROM authors_cursorFETCH NEXT FROM authors_cursorFETCH NEXT FROM authors_cursorCLOSE authors_cursorDEALLOCATE authors_cursor
(Assume that authors table has 200 author profiles)
What is the outcome of executing the above cursor statements?"
1 Three author profiles are retrieved from authors2 One author profile is retrieved from authors3 No author profiles are retrieved from authors4 Four author profiles are retrieved Y5 Gives error message fast forward allows next
195 Consider the following cursor processing:
DECLARE authors_cursor FAST_FORWARD FORSELECT au_lname, au_fname FROM authorsORDER BY au_lname, au_fnameOPEN authors_cursorFETCH NEXT FROM authors_cursorFETCH RELATIVE 7 FROM authors_cursorFETCH ABSOLUTE 5 FROM authors_cursorFETCH LAST FROM authors_cursorCLOSE authors_cursorDEALLOCATE authors_cursor
(Assume that authors table has 200 author profiles)
What is the outcome of executing the above cursor statements?"
1 Three author profiles are retrieved from authors2 One author profile is retrieved from authors3 No author profiles are retrieved from authors4 Four author profiles are retrieved5 Gives error message Y with fast forward next only is
allowed
196 Consider the following temporary stored procedure:
CREATE PROCEDURE #use_tempASSELECT 1/0RETURN @@ERRORGOThe following statements are executed in a procedure:IF NOT EXISTS(SELECT productid FROM production.product WHERE color = 'yellow' )BEGIN RETURNEND
SELECT productid FROM production.product WHERE color = 'yellow'DECLARE @ErrorCode INTEXEC @ErrorCode INT = #use_tempPRINT @ErrorCode
Assuming that there is no product with yellow color, what is the final outcome of executing as above?"
1 Prints error message and error code2 Executes with no message Y
3 Severe database error4 None of the listed options since not exists
is satisfied,just returns no message
197 Consider the following temporary stored procedure:
CREATE PROCEDURE #use_tempASSELECT 1/0RETURN @@ERRORGOThe following statements are executed in a procedure:IF NOT EXISTS(SELECT productid FROM production.product WHERE color = 'yellow' )BEGIN RETURNEND
SELECT productid FROM production.product WHERE color = 'red'DECLARE @ErrorCode INTEXEC @ErrorCode INT = #use_tempPRINT @ErrorCode
Assuming that the database has products with red, yellow and blue colors, what is the final outcome of executing as above?"1 Prints error message and error code Y
2 Executes with no message
3 Severe database error
4 None of the listed options since temp proc is invoked, it gives 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' ENDFROM 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" Y
5 None of the listed options regular case is converted to boolean case as in 4
199 Consider the following cursor processing:
The following procedures are created:
CREATE PROC sp_twoASSET NO COUNT ONFETCH C1RETURNGO
CREATE PROC sp_oneASSET NO COUNT ON DECLARE CURSOR C1 GLOBAL FOR SELECT titleid, type from titles OPEN C1 FETCH C1 EXEC sp_two CLOSE C1 DEALLOCATE C1GO(Assume that titles table has 100 book titles)
How many book titles are retrieved when proc sp_one is executed?"
1 One book title2 Two book titles Y3 None4 Gives execution error since global cursor is
declared, fetch in sp_two works
200 Consider the following cursor processing:
The following procedures are created:
CREATE PROC sp_twoASSET NO COUNT ONFETCH C1RETURNGO
CREATE PROC sp_oneASSET NO COUNT ON DECLARE CURSOR C1 LOCAL FOR SELECT titleid, type from titles OPEN C1 FETCH C1 EXEC sp_two CLOSE C1 DEALLOCATE C1GO(Assume that titles table has 100 book titles)
What are the possible outcomes when proc sp_one is executed?(Choose 2)"
1 One row is fetched from titles Y
2 Two rows are fetched from titles
3 No rows are fetched from titles
4 Gives error message Y since local cursor used, only one 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 au_fname
BHARAT IYER
ASHISH MALHOTRA
BIDYUT THAKUR
ANISH MATRE
BALA 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 EMPLOYEEORDER BY EMPNAMEFOR XML RAW
SELECT * FROM EMPLOYEEORDER BY EMPNAMEFOR XML RAW ,XSINIL
SELECT * FROM EMPLOYEEORDER BY EMPNAMEFOR XML RAW ,ELEMENTS
SELECT * FROM EMPLOYEEORDER BY EMPNAMEFOR XML ELEMENTS
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 EMPLOYEEORDER BY EMPNAMEFOR XML ELEMENTS ROOT('ROOT')
SELECT * FROM EMPLOYEEORDER BY EMPNAMEFOR XML RAW('ROW!'),ELEMENTS ROOT('ROOT')
SELECT * FROM EMPLOYEEORDER BY EMPNAMEFOR XML RAW,ELEMENTS ROOT('ROW')
SELECT * FROM EMPLOYEEORDER BY EMPNAMEFOR XML RAW,ELEMENTS ROOT('ROOT')
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 '[email protected]'.
She needs to find out the tag which contains the value as '[email protected]' and replace it with another value.
Which of the following clause helps her in replacing the Value?
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 Contents
1 table
5 Chair
Here is the XML result from a Query.
<ROOT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CHILD>
<id>1</id>
<contents>table</contents>
</CHILD>
<CHILD>
<id>5</id>
<contents>chair</contents>
</CHILD>
</ROOT>
Identify the Query which gave the above Result?
SELECT * FROM SALES ORDER BY IDFOR XML RAW('CHILD'),Elements XSINIL, ROOT('ROOT')
SELECT * FROM SALES ORDER BY IDFOR XML RAW('CHILD'),Elements, ROOT('ROOT')
SELECT * FROM SALES ORDER BY IDFOR XML RAW('CHILD'), XSINIL, ROOT('ROOT')
SELECT * FROM SALES ORDER BY IDFOR XML RAW('CHILD'),Elements XSINIL
-----------------------
221. Consider the following statement:
SELECT * FROM SALES JOIN PURCHASE on PURCHASE.ID=SALES.IDFOR 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.JOIN3.PURCHASE on PURCHASE.ID=SALES.ID4.FOR XML RAW('CHILD'),Elements XSINIL, ROOT('ROOT'),XMLSCHEMA5.BINARY
Which of the following can be added in the 5th line from the following which helps in Encoding the Binary data that is Supported in SQL Server 2005?
a. BASE32
b. BASE64
c. ENCODE32
d. ENCODE64
223. Consider the following item table and the statement:
ITEM ID CONTENTS 1 Table 2 Chair
Select 123 as Tag, 0 as Parent, Contents as[contentsTable!123!contents] from item for xml EXPLICIT
What is the result of the above statement?
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 ITEMFOR XML PATH('PRODUCT'),ROOT('PRODUCTITEM')
2.SELECT * FROM ITEM FOR XML RAW('PRODUCT'),ELEMENTS,ROOT('PRODUCTITEM')
Choose the correct option based on the output from the above two statements.
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 ITEMFOR 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 ITEMFOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT')
b. SELECT ID,CONTENTS 'innerstring()' FROM ITEMFOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT')
c. SELECT ID,CONTENTS 'text()' FROM ITEMFOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT')
d. Error in the above statement
227. Consider the following ITEM table and the statement:
ID CONTENTS 1 Table 2 Chair
SELECT CONTENTS 'processing-instruction(CONT)',(select ID 'data()'from item for xml path('')) 'work/worker/@id' FROM ITEMFOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT')
What is the result of the above statement?
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 ITEMFOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT')
b. SELECT ID, 'Comments: ' + contents 'comment()' FROM ITEMFOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT')
c. SELECT ID, contents 'comment()' + ' Comments :' FROM ITEMFOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT')
d. SELECT ID, contents as 'comment()' FROM ITEMFOR 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 ITEMFOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT')
b. SELECT ID, contents as 'tagname/@contents' FROM ITEMFOR XML PATH('PRODUCTITEMS'),ROOT('PRODUCT')
c. SELECT ID, contents 'tagname/contents' FROM ITEMFOR 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')>600004.ORDER BY XS:NAME(STRING($ADDRESS/NAME)) DESCRETURN<PIN>823456</PIN>)AS RESULTFROM CONTACT_DETAILS WHERE emp_id=10
Which of the following iterator or clause is not supported in SQL Server of the above numbered statement?
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 tablesStatement 2: While Identifying the Join clause, query optimizer treats SELF JOIN as a single table
Which of the following is applicable for the above statements?
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 SNAPSHOTgobegin transelect * from bookgoId Title--- ------2 Catch-223 Roses in December
User 2 - BEGIN TRANupdate book set Title = ‘Roses in December Edition 2’where id = 3go
User 1 -
update book set Title = ‘My Experiments with Truth’where id = 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 JOINEMP_SALARYDETAILSONEMP_DETAILS.EMP_ID=EMP_SALARYDETAILS.EMPIDWHERE EMPID=1001 OR EMPID =1002
Identify the order of optimization of the following clausesa.INNER JOINb.WHEREc.OR
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 TRANSACTION23 BEGIN TRY4 UPDATE . . .56 END TRY78 BEGIN CATCH9 IF . . .1011 END CATCH12
Give the line number, where the ROLLBACK statement would normally be placed?
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 TRANSACTION23 BEGIN TRY4 UPDATE . . .56 END TRY
78 BEGIN CATCH9 IF . . .1011 END CATCH12
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 tran2 update account set balance = balance - 1000 where account_number = 123 3 if @@error != 04 begin5 rollback tran6 return7 end8 update account set balance = balance + 1000 where account_number = 4569 if @@error != 010 begin11 rollback tran12 return13 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_book2 insert book (id, name) values (2, ‘SQL for dummies’)3 if @@error = 500004 begin5 rollback tran add_book6 return7 end8 save tran keep_the_first09 insert book (id, name) values (3, ‘20 immutable laws of leadership’)10 if @@error = 5000011 begin12 rollback tran keep_the_first13 end14 commit tran
If the error code returned by line 10 is 50000, what will be the outcome?
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_book2 insert book (id, name) values (2, ‘SQL for dummies’)3 if @@error = 500004 begin5 rollback tran add_book6 return7 end8 save tran keep_the_first09 insert book (id, name) values (3, ‘20 immutable laws of leadership’)10 if @@error = 5000011 begin12 rollback tran keep_the_first13 end14 commit tran
If the error code returned by line 3 is 50000, what will be the outcome?
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 XMLSET @XMLVAR='<INDIA><STATES> <STATE SNO="1" SNAME="TN" /></STATES><STATES> <STATE SNO="2" SNAME="AP" /></STATES><STATES> <STATE SNO="3" SNAME="UP" /></STATES></INDIA>' SELECT XMLTABLE.XMLCOLUMN.query('SNAME') AS node, XMLTABLE.XMLCOLUMN.VALUE('STATE[1]/@SNO','CHAR(1)') AS STATE_CODEFROM @XMLVAR.nodes('/INDIA/STATES') AS XMLTABLE(xmlcolumn)
What is the result of the above statement?
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