SQL SERVER Weekly Test2 Complex Questions

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 24

WEEKLY TEST 2

Question1. You are working as a database developer at CMC. CMC has a database
named HumanResources that contain information about all employees and office
locations. The database also includes information about potential employees and office
locations, which are stored in the tables as shown in the exhibit below:

Existing employees are assigned to a location and existing location have one or more
employees assigned to them. Potential employees are not assigned to a location, and
potential office locations do not have any employees. You have received instruction
from CEO to create a report that displays all existing and potential employees and office
locations. The report has to list every existing and potential location, followed by any
employees who have been assigned to that location. Also, potential employees have to
be listed together.

Of the following script, which is the one you should employee to achieve this objective?

A.
SELECT l.LocationName, e.FirstName, e.LastName
FROM Employee AS e LEFT OUTER JOIN Location as l
ON e. LocationId = l. LocationId
ORDER BY l.LocationName, e.FirstName, e.LastName

B.
SELECT l.LocationName, e.FirstName, e.LastName
FROM Location AS l LEFT OUTER JOIN Employee as l
ON e. LocationId = l. LocationId
ORDER BY l.LocationName, e.FirstName, e.LastName

C.
SELECT l.LocationName, e.FirstName, e.LastName
FROM Employee AS e FULL OUTER JOIN Location as l
ON e. LocationId = l. LocationId
ORDER BY l.LocationName, e.FirstName, e.LastName

D.
SELECT l.LocationName, e.FirstName, e.LastName
FROM Employee AS e FULL OUTER JOIN Location as l
ORDER BY l.LocationName, e.FirstName, e.LastName

Answer - c
Question2. There are two tables as shown in the exhibit below:-

Create table Countries


(
CountryID int IDENTITY(2,2) NOT NULL,
CountryName char(20) NOT NULL,
)

Create table Instructors


(
InstructorID int NOT NULL,
FirstName char(20) NOT NULL,
LastName char(20) NOT NULL,
Title char(5) Null,
Country char(20) NULL
)

You must populate the Countries table by moving the country information from the
Instructors table to the Countries Table. You must accomplish this task by using cursor.
Write Transact-SQL query to accomplish the job.

ANSWER.
DECLARE @Country char(20)
DECLARE cursor_country CURSOR
FOR SELECT Country FROM Instructors
OPEN cursor_country
FETCH NEXT FROM Instructors into @Country
WHILE @@FETCH_STATUS=0
BEGIN
IF NOT EXISTS (SELECT CountryID FROM Countries WHERE
CountryName=@Country)
INSERT INTO Countries(CountryName)VALUES (@Country)
FETCH NEXT FROM Instructors into @Country
END
CLOSE cursor_country
DEALLOCATE cursor_country

Question3. All customer companies that purchase significant amount of products are
offered discounts. Prices of the products with a category ID of 15 have been increased
by 10%. To compensate for customer companies that placed there orders on the day of
the price increase the discounts for those products must also be increased by 10%.
Both UPDATE statements must be implemented together. In the event of either update
failing, then the other update must not be implemented.

What should you do?

A. You should use the following script:

BEGIN TRAN
UPDATE Products SET Unitprice = Unitprice * 1.1 WHERE CategoryID =15
UPDATE OrderDetails SET Discount=Discount*1.1
FROM OrderDetails od JOIN Products p ON od.PRODUCTID= p.PRODUCTID
JOIN orders o ON o.OrderID= od. OrderID
WHERE CategoryID =15 AND OrderDate= '18 NOV 2013'
COMMIT

B. You should use the following script:

UPDATE Products SET Unitprice = Unitprice * 1.1 WHERE CategoryID =15


UPDATE OrderDetails SET Discount=Discount*1.1
FROM OrderDetails od JOIN Products p ON od.PRODUCTID= p.PRODUCTID
JOIN orders o ON o.OrderID= od. OrderID
WHERE CategoryID =15 AND OrderDate= '18 NOV 2013'

C. You should use the following script:

BEGIN TRAN
UPDATE Products SET Unitprice = Unitprice * 1.1 WHERE CategoryID =15
COMMIT

BEGIN TRAN
UPDATE OrderDetails SET Discount=Discount*1.1
FROM OrderDetails od JOIN Products p ON od.PRODUCTID= p.PRODUCTID
JOIN orders o ON o.OrderID= od. OrderID
WHERE CategoryID =15 AND OrderDate= '18 NOV 2013'
COMMIT

ANSWER. A

create table Mytrantest


(
OrderId int Primary key Identity

Begin tran Transtart


Insert into Mytrantest
default values
Save tran firstpoint

insert into Mytrantest


default values

rollback tran firstpoint

Commit tran transtart

Select * from Mytrantest

Answer - 1
Question2. You are creating a stored procedure that will be called by an application and
will access data stored in one of the databases. The stored procedures must be
configured to return the current value of a parameter to the calling application. What
must you do?

A. Specify an output parameter in the stored procedure using the OUTPUT keyword.
B. Include a select statement in the stored procedure to return the necessary value
C. Specify a return code for the stored procedure using the RETURN statement.
D. Declare a variable using the DECLARE statement

Answer - A

Question3. You have created a view that reference columns from multiple base tables.
You want to modify data in the underlying tables through the view using an UPDATE
statement. What must be done to allow this modification to occur?

A. Create an AFTER trigger to execute after the UPDATE trigger.


B. Alter the view definition to include the SCHEMABINDING clause.
C. Create an INSTEAD OF UPDATE Trigger to make the required changes.
D. Nothing; executing the UPDATE statement with the required changes is all needed.

Answer - C

Question4. Company policy requires that all sessions accessing the database be
insulated from dirty reads. Non Repeatable reads and phantom reads are acceptable.
What is the lowest isolation level you can set to meet theses requirement ?

A. Read Uncommited
B. Read Commited
C. Repeatable Read
D. Serializable

Answer - B

Scenario Based Question: - There are two tables (User & UserHistory) as shown
below:-

User
user_id
name
phone_num
UserHistory
user_id
date
action

Given the tables above, find the following:

Question5. Given the tables above, write a SQL query to determine which user_ids in the User
table are not contained in the UserHistory table (assume the UserHistory table has a subset of
the user_ids in User table).

Answer. select u.user_id


from User as u
left join UserHistory as uh on u.user_id=uh.user_id
where uh.user_id is null

Question6. What does this return?

create table Mytrantest


(
OrderId int Primary key Identity

Begin tran Transtart


Insert into Mytrantest
default values
Save tran firstpoint

insert into Mytrantest


default values

rollback

Select * from Mytrantest

Answer. No value will return

Question7. Scenario Based Question: - There are two tables (Salesperson, Customer&
Orders) as shown below:-

Salesperson Customer
ID Name Age Salary ID Name City Industry Type
1 Abe 61 140000 4 Samsonic pleasant J
2 Bob 34 44000 6 Panasung oaktown J
5 Chris 34 40000 7 Samony jackson B
7 Dan 41 52000 9 Orange Jackson B
8 Ken 57 115000
11 Joe 38 38000
Orders
Number order_date cust_id salesperson_id Amount
10 8/2/96 4 2 2400
20 1/30/99 4 8 1800
30 7/14/95 9 1 460
40 1/29/98 7 2 540
50 2/3/98 6 7 600
60 3/2/98 6 7 720
70 5/6/98 9 7 150

Question7. Find the largest order amount for each salesperson and the associated order number,
along with the customer to whom that order belongs to.

Answer.
select ord.sales_id, sp.name,number as OrderNumber, cust_id ,amount from
orders ord
JOIN
salesperson sp
on sp.sales_id= ord.sales_id
JOIN
(select sales_id , MAX(amount)mx from orders group by sales_id)maxord
on ord.amount= maxord.mx

Question8. Write syntax to create a View name CustomerOrders_vw to display amount of each
salesperson and the associated order number, along with the salesperson name.

Answer.

CREATE VIEW Customerorders_vw


As
Select name ,number, order_date,amount
FROM dbo.Salesperson sp
Join dbo. orders ord
ON sp.sales_id=ord.sales_id

Question9. Write syntax to encrypt the above View name CustomerOrders_vw.

Answer.

ALTER VIEW Customerorders_vw


WITH ENCRYPTION
As
Select name ,number, order_date,amount
FROM dbo.salesperson sp
Join dbo.orders ord
ON sp.sales_id=ord.sales_id

Question10. Write syntax to drop the above View name CustomerOrders_vw.

Answer.
DROP VIEW Customerorders_vw
Question11. Write syntax to alter the above View name CustomerOrders_vw in order to bind with
underlying tables
Answer.

ALTER VIEW Customerorders_vw


WITH SCHEMABINDING
AS
SELECT name ,number, order_date,amount
FROM dbo.salesperson sp
Join dbo.orders ord
ON sp.sales_id=ord.sales_id.

Question12. You have created the stored procedure, shown below, to report the year-to-date sales
for a specific book title.

Create procedure get_sales_for_title


@title varchar(80), @ytd_sales int output
AS
SELECT @ytd_sales= ytd_sales from titles where title=@title
IF @@rowcount=0
Return (-1)
Else
Return 0

You are now creating a script that will perform this stored
procedure. The stored procedure should report the year-to-date
sales for the book title if it executes successfully. If,
however, the stored procedures fails to execute, it should
report following message:
‘ No Sales Found’
Which of the following illustrates how the script required to
achive this should be created?
A.Declare @retval int
Decalre @ytd int
Exec get_sales_for_title ‘Net Etiquette’,@ytd
IF @retval <0
Print ‘No Sales found’
ELSE
Print ‘Year to date sales: ‘+STR(@ytd)
GO

B.Declare @retval int


Decalre @ytd int
Exec get_sales_for_title ‘Net Etiquette’,@ytd OUTPUT
IF @retval <0
Print ‘No Sales found’
ELSE
Print ‘Year to date sales: ‘+STR(@ytd)
GO

C. Declare @retval int


Decalre @ytd int
Exec get_sales_for_title ‘Net Etiquette’,@retval OUTPUT
IF @retval <0
Print ‘No Sales found’
ELSE
Print ‘Year to date sales: ‘+STR(@ytd)
GO

D. Declare @retval int


Decalre @ytd int
Exec @retval=get_sales_for_title ‘Net Etiquette’,@ytd OUTPUT
IF @retval <0
Print ‘No Sales found’
ELSE
Print ‘Year to date sales: ‘+STR(@ytd)
GO

Answer. D

Question13. What does this return?

create table UnionTest1


(
idcol int IDENTITY,
col2 char(3)
)

create table UnionTest2


(
idcol int IDENTITY,
col4 char(3)
)

Insert into UnionTest1


VALUES ('AAA')
Insert into UnionTest1
VALUES ('BBB')
Insert into UnionTest1
VALUES ('CCC')

Insert into UnionTest2


VALUES ('CCC')

Insert into UnionTest2


VALUES ('DDD')

Insert into UnionTest2


VALUES ('EEE')

SELECT col2 from UnionTest1


UNION ALL
SELECT col4 from UnionTest2
Answer.
col2
----
AAA
BBB
CCC
CCC
DDD
EEE

Question14. What would happen when you execute the code given below in query
Analyzer?

create PROCEDURE sp_who


AS
PRINT 'SURPRISE'
GO
EXECUTE sp_who

Answer. Information about current SQL Server users and processes is displayed.
The explanation could be found in the Books Online under Creating a Stored
Procedure. One of the sections, named System Stored Procedures which describes
how SQL Server looks up the system stored procedure has this note: Important If any
user-created stored procedure has the same name as a system stored procedure, the
user-created stored procedure will never be executed.

Question15. On Friday, you issued several INSERT statements using Query Analyzer.
You then verified the data had been correctly entered with a SELECT statement. On
Monday, your users report that data is not there. What happened?
Answer. IMPLICIT_TRANSACTION mode was enabled (on) for the connection.

In this mode, after inserting or updating the data, you must issue the COMMIT
TRANSACTION statement to save the data permanently. Otherwise, once the
connection is broken all your inserts are rolled back.

. You want to create a table to store Microsoft Word Document. You need to ensure that
the documents must only be accessible via Transact SQL Queries. Which T-SQL
Statement should you use?

A. Create table DocumentStore


(Id INT NOT NULL PRIMARY KEY,
Document VARBINARY (MAX) NULL
)
B. Create table DocumentStore
(Id hierarchyid,
Document VARBINARY NOT NULL
)
C. Create Table DocumentStore as FileTable
D. None of the Above

Answer10. A

Question11. What does this return:-

SELECT DB_NAME();

A. MASTER
B. MODEL
C. MSDB
D. Current Database Name in which the Query is executed.

Answer11. D

Question12. You are designing a database for Microsoft.com. The database must
accommodate the customers who want to make reservation online to sit for examination.
To make a reservation, a new customer is required to provide his name, telephone number,
address and relevant examination information. Once a reservation has been confirmed, the
customer will receive a unique customer number, a unique reference number that pertains to
the reservation. The information includes details such as vendor, examination number, name of
certification and date and time of reservation.

1. To make another reservation at a later time, the customer must provide his customer
number.
2. To change existing reservation, the customer must provide the reservation reference
number.
Examination numbers are assigned according to the certification that it contributes toward and
are independent from vendor to vendor. Each vendor may offer one or more examination
towards certain certification. The database should be normalised to the third normal form. You
create the following tables:-
Create table Examinations
(Vendor int,
ExamID int,
Certification nvarchar (20))
Create table TimeTable
(Vendor int,
ExamID int,
ExamDate datetime)

Now you need to define the foreign keys for these tables. Write a script to define foreign keys
for these tables.

Answer12. Alter table Examinations ADD PRIMARY KEY (ExamID, Vendor)


Alter table TimeTable ADD PRIMARY KEY (ExamID, Vendor, ExamDate)

Question13. You are asked to design tables for this database, and come up with the design
shown in the exhibit below:

Which of the following is the option that you should take if you want to minimize redundant
data?

A. Create a new table named Instructors. Include an InstructorID column, and


InstructorName column, and OfficePhone column. Add and InstructorID column to the
Courses table.
B. Move all the columns from the Classroom table to the Courses table, and drop the
Classroom table.
C. Remove the Primary Key constraint from the Courses table, and replace the PRIMARY
KEY constraint with a composite PRIMARY KEY constraint based on the CourseID and
CourseTitle.
D. None of the above.

Question14. You work as a database developer. The exhibits show a table:-

Which two of the followings are the columns that you should use to uniquely identify the skills of
each candidate?

A. CandidateID
B. SkillID
C. DateLastUsed
D. Proficiency

Answer14. A, B

Question15. You are currently designing a database named Sales. You have 1 GB of free
space on drive C and the database will be approximately 10 MB in size. Write the script to
create the database.

Answer15. Create Database Sales


ON
(Name =Sales_dat,
FILENAME= ‘c:\data\contacts.mdf’, SIZE=10MB, MAXSIZE= 50MB, FILEGROWTH
=5MB )
LOG ON
(Name= Sales_log,
FILENAME = ‘c:\data\saleslog.ldf’, SIZE=5MB, MAXSIZE= 25MB, FILEGROWTH
=5MB)

Question16. Which of the following is true?


A. NULL Values are ignored for all the aggregate functions.
B. NULL Values are included for all the aggregate functions.
C. When an aggregate function is included in the SELECT clause, all other expression in
the SELECT clause must either be aggregate functions or included in a GROUP BY
clause.
D. None of the above

ANSWER16. A and C

Question17. Assuming UserProfile is a table containing a column Profession which accepts


NULL value. What is the result of the below query:-

SET ANSI_NULLS OFF


SELECT Profession
FROM UserProfile
WHERE (Profession <> NULL)

Select Answer:

A. Returns all Professions which has not null values.


B. Gives an error.
C. <> is not an operator in SQL Server
D. None of the above.

ANSWER17. A

Question18. Which of the following are new SQLSERVER 2008 date functions?

Select Answer:

A. SYSDATETIME
B. SYSDATETIMEOFFSET
C. SYSUTCDATETIME
D. All of the above.

ANSWER18. A

Question19. Assuming UserProfile is a table containing a column Profession which accepts


NULL value. What is the result of the below query.
SET ANSI_NULLS ON
SELECT Profession
FROM UserProfile
WHERE (Profession <> NULL)
Select Answer:

A. Returns records which has values in profession column


B. Gives an error
C. Does not retrieve any records even if profession column contains values.
D. None of the above.

ANSWER19. A

Question20. Which of the following queries returns the users whose username starts with any of
the character between v to z?

Select Answer:

A. SELECT PKUserId, UserName FROM UserProfile WHERE (UserName LIKE '[v-z]%')


B. SELECT PKUserId, UserName FROM UserProfile WHERE (UserName LIKE '[vz]%')
C. SELECT PKUserId, UserName FROM UserProfile WHERE (UserName LIKE '[v-z%]')
D. None of the above

ANSWER20. A

Question21. If the following code was run on 31st Dec 2011, What is the result of the below
query:
SELECT DATEDIFF(YEAR, GETDATE(), '8/8/2003') AS 'Difference'

Select Answer:

A. -8
B. 8
C. 0
D. -1

ANSWER21. A

Question22: Assuming UserProfile is a table with PKUserId int, Profession Varchar(50)


columns. What is the result of the below query: SELECT PKUserId, Profession
FROM UserProfile
WHERE Profession = 'Engineer' AND (PKUserId > 12 OR PKUserId = 1)

Select Answer:
A. Displays Users with Profession as 'engineer' with PKUserId > 12 as well as the users
with PKUserId of 1
B. Displays Users with Profession as 'engineer' with PKUserId > 12 only
C. Displays Users with Profession as 'engineer' with PKUserId of 1 only
D. None of the above

ANSWER22. A

Question23: Which of the following is correct?

Select Answer:

A. The DELETE statement logs information on each row deleted


B. The TRUNCATE TABLE statement logs information on each row deleted
C. The TRUNCATE TABLE statement executes fast and requires fewer resources on the
server
D. All of the above
E. Only A and C

ANSWER23. E

Question24. What is the result of the below query:


SELECT PATINDEX('DOT%', 'DOTNET') AS 'Index'

Select Answer:

A. 1
B. 0
C. -1
D. 2

ANSWER24. A

Question25. Which of the following are T-SQL ranking functions that can be used for ranking
data

Select Answer:

A. ROW_NUMBER
B. DENSE_RANK
C. RANK
D. NTILE
E. All of the above
ANSWER25. E

Question26. What is the result of the below query:


SELECT SUBSTRING('DOTNET', 1, 3) AS 'Substring'

Select Answer:

A. DOT
B. OTN
C. OT
D. None of the above

ANSWER26. A

Question27. Assuming the following query is executed on 31st Dec 2011. What is the result of
the below query.
SELECT CONVERT (varchar (30), GETDATE (), 111) AS Expr1

Select Answer:

A. 11/12/31
B. 31/12/11
C. 31/12/2011
D. 2011/12/31

ANSWER27. D

Question28. What is the output of the below query:-

SELECT REPLACE (‘abcdefghicde’,’cde’,’yyy’);

Answer28. abyyyfghiyyy

Question29. What is the output of the below query:-

SELECT REPLACE ('Das ist ein Test’ COLLATE


Latin1_General_BIN,
'Test', 'desk');

Answer29. Das ist ein desk


Question30. What is the output of the query?

SELECT LEFT ('abcdefg',2)

Answer30. ab

Question31. What is the output of the query?

SELECT RIGHT ('abcdefg',2)

Answer31. fg

Question32. You have to create table as per the design as shown below:

Write the Syntax to Create the Table as per above schema.

Answer32.
Create table Customers
(CustmerID int PRIMARY KEY,
CompanyName nvarchar (30),
Address nvarchar (50),
City nvarchar (20))

Create table Invoices


(InvoiceNo int PRIMARY KEY,
CustomerID int FOREIGN KEY REFERENCES Customers (CustomerID))
Question33. You have recently received instruction to implement a SQL Server 2008 database
that will be used to store business information. A table named Test will be used to store sales
information and each sale will be uniquely identified by a specific SaleNo column. What should
you do?

A. You should define a PRIMARY KEY constraint on the SaleNo column.


B. You should specify the unique identifier data type for the SaleNo Column
C. You should specify ROWGUID property for the SaleNo Column
D. You should specify IDENTITY property for the SaleNo Column

Answer33. A

Question34. What does this return:-

Select DATETIME (2008, 8, 5, 6, 57, 32)

Answer34. 8/5/2009 6:57:32 AM

Question34. COUNT_BIG () returns a value of which data type:-

A. int
B. smallint
C. bigint
D. tinyint

Answer34. C

Question35. COUNT () returns a value of which data type:-

A. int
B. smallint
C. bigint
D. tinyint

Answer35. A

Question36. COUNT () returns a value of which data type:-

A. int
B. smallint
C. bigint
D. tinyint
Answer36. A

Question37. Assuming the following query is executed on 27st Oct 2013. What is the result of
the below query.
SELECT CONVERT (char (12), GETDATE (), 3) AS Expr1

Select Answer:

A. 27/10/13
B. 27/10/2013
C. 2013/10/27
D. 13/10/27

ANSWER37. A

Question38. What is the result of below query?

USE tempdb;
GO
DECLARE @Num1 int;
SET @Num1 = -5;
SELECT ABS(@Num1);
GO

ANSWER38. 5

Question39. What is the result of below query?

USE tempdb;
GO
DECLARE @Num1 int;
SET @Num1 = -5;
SELECT +(@Num1);
GO

ANSWER39. -5
Question40. What does this return?

create table MyTable


( Mychar varchar(20))
go
insert Mytable select 'Apple'
insert Mytable select 'Ball'
insert Mytable select 'Cat'
go
select * from MyTable where Mychar like '[a]%'

Answer40. Apple

Question41. What does this return?

SELECT ContactID, FirstName, LastName


FROM Person.Contact
WHERE FirstName LIKE '[CS]heryl';
GO

A. The following query finds Contacts with the first name of Cheryl or Sheryl.
B. The following query finds Contacts not with the first name of Cheryl or Sheryl.
C. All of the above
D. None of the Above

Answer41. A

Question42. What does this return?

create table MyTable


( Mychar varchar(20))
go
insert Mytable select 'Apple'
insert Mytable select 'Ball'
insert Mytable select 'Cat'
go
select * from MyTable where Mychar Not like '[a]%'

Answer42. Ball & Cat

Question43. Which conversion will truncate extra decimal digits instead of


rounding?
A. Numeric to money

B. Numeric to int

C. Money to int

D. Money to numeric

Answer43. B

Question44. You are asked to review the below query:-

Exhibit

SELECT t1.column1, t1.column2


FROM table1 AS t1
WHERE EXISTS (
SELECT * FROM table2 AS t2
WHERE t2.column1 = t1.column1
)

Which advanced querying technique is used in the exhibit’s code?

A. Non-correlated subquery

B. Cross apply

C. Correlated subquery

D. Full outer join

Answer44. C

Question45. Write a Query that will retrieve all products from the db.products
table that have a name that starts with a letter in the range of G through M.

Answer45.
SELECT * from dbo.products
WHERE name like ‘[g-m]%’

Question46. The following SQL Statement was used to create a table:-

SQL Statement

CREATE TABLE dbo.customers


(
customer_id INT PRIMARY KEY,
customer_name INT,
customer_address NVARCHAR(max),
)

Running a select statement against the table produces following result set:-

Results
customer_id customer_name customer_address

1 Earth Farm Dallas

2 Imagenie Corp. London

3 Easy Nomad Ltd. Seattle

4 Gleeson Associates Boston

5 Quick 24x7 Bangalore

6 Mathemetric Ltd. St. Petersburg

Mathemetric Ltd. Currently changes its corporate name to Zoflina. You need to
modify the dbo.customers table to reflect this change. Which SQL statement
should you use?

A. Update dbo.customers set customer_name =’Zoflina’ where customer_name


=’ Mathemetric Ltd.’

B. Update dbo.customers set customer_name =’Zoflina’ where customer_id =’ 5’

C. Update dbo.customers where customer_id =’ 5’ set customer_name =’Zoflina’

D. None of the above

Answer46. A

Question47. You are designing a table for multimedia department. They require a column to
store large video files. The file size can range up to 4GB. Which data type should you select for
the columns?
A. Binary
B. Varbinary(max)
C. Image
D. FILESTREAM varbinary(max)

Answer47. D
Question48. There are two tables named table1 and table2. Both tables have same number of
columns. The columns appear in the same order and have same data types. You need to
develop a T-SQL statement that will return all rows in table1 that do not also appear in table2.
Which statement will return the proper results?

A. SELECT * from table1


Union
Select * from table2

B. SELECT * from table1


INTERSECT
Select * from table2

C. SELECT * from table1


UNION ALL
Select * from table2

D. SELECT * from table1


EXCEPT
Select * from table2

Answer48. D

Question49. You need to write a query that will return all employees whose salaries are
higher than the average salary of all employees.
Which of the following option will meet your need?

Options

OPTION A:

SELECT name, department, salary


FROM HR.Employees
WHERE salary > (
SELECT AVG(salary)
FROM HR.Employees
)

OPTION B:

SELECT name, department, salary


FROM HR.Employees
WHERE salary = (
SELECT AVG(salary)
FROM HR.Employees
)

OPTION C:

SELECT name, department, salary


FROM HR.Employees
WHERE salary > ALL (
SELECT salary
FROM HR.Employees
)

OPTION D:

SELECT name, department, salary


FROM HR.Employees
WHERE salary > ANY (
SELECT AVG(salary)
FROM HR.Employees
GROUP BY department
)

Answer49. Option A

Question50. You need to delete all rows the dbo.orders table. The following requirement must
be met:-
- Minimal transaction log space must be used
- Locks must be kept to minimum
- The structure of the table and table definition must remain
Which T-SQL statement will accomplish for you?

A. DELETE
B. TRUNCATE TABLE
C. DROP TABLE
D. REVOKE

Answer50. B

You might also like