Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

SQL Assessment | 30 Questions | 60 minutes

1. Which of the following is not a valid SQL type?

A. DECIMAL
B. NUMERIC
C. FLOAT
D. CHARACTER

2. A company has a SQL Server database instance that hosts a database named
ComDB. The ComDB database has a table named Partners that was created using the
following Transact-SQL code:

CREATE TABLE [dbo].[Partners]


(
[CompanyID] [int] NOT NULL,
[CompanyName] [nvarchar] (50) NOT NULL,
[Location] [nvarchar] (50) NOT NULL,
[ContactName] [nvarchar] (50) NOT NULL,
[Email] [nvarchar] (50) NOT NULL,
[Phone] [nvarchar] (10) NOT NULL,
CONSTRAINT [PK_Partners] PRIMARY KEY CLUSTERED
(
CompanyID] ASC
)
ON PRIMARY
)

You want to create a FOR UPDATE trigger that will track changes to the ContactName
and Phone columns. Which of the following statements should you use in the trigger
definition?

A. IF COLUMNS_UPDATED (ContactName, Phone)


B. IF COLUMNS_UPDATED (ContactName) OR COLUMNS_UPDATED (Phone)
C. IF UPDATED (ContactName, Phone).
D. IF UPDATED (ContactName) OR UPDATED (Phone)

3. You are the database administrator of a SQL Server database infrastructure in one company.
You need to optimize a very large database table that contains several million rows of data by
designing a view based on the table. The view must allow users to perform aggregations on
several columns.

How should you configure the view to ensure optimal performance?

A. You should create the view as an indexed view.


B. You should create a clustered index on the view.
C. You should make use of a stored procedure to return that data.
D. You should make use of a table-valued function.
1|Page

SQL Assessment | 30 Questions | 60 minutes


4. You are the database developer in a company. It has a SQL Server database infrastructure
that has a database named ComDB with a table named Partners. The Partners table was
created using the following Transact-SQL code:

CREATE TABLE [dbo].[Partners]


(
[CompanyID] [int] NOT NULL PRIMARY KEY,
[CompanyName] [varchar] (150) NOT NULL,
[Location] [varchar] (150) NOT NULL,
[ContactName] [varchar] (150) NOT NULL,
[Email] [varchar] (150) NOT NULL,
[Phone] [varchar] (10) NOT NULL
)

You develop a new table named Events using the following Transact-SQL code:

CREATE TABLE [dbo].[Events]


(
[EventID] [int] NOT NULL PRIMARY KEY,
[CompanyID] [int] NOT NULL,
[EventDescription] [varchar] (2500),
[EventCordinator] [varchar] (150) NOT NULL
)
How would you guarantee that values in the Events.CompanyID column already
exist in the Partners.CompanyID column?

A. You should add a Foreign Key Constraint on the Events table.


B. You should add a Check Constraint on the Events table.
C. You should add a Unique Constraint on the Events table.
D. You should specify Events.CompanyID as a spars column

5. You work as a SQL Server database developer. Your company has a database named
SalesDB. You are developing a stored procedure that takes a parameter named @date that
uses the varchar datatype. The @date parameter must be compared to the value in a
datetime column named OrderDate. Which of the following WHERE clauses would be the
most efficient WHERE clause to use?

A. WHERE OrderDate = CAST(datetime,@date)


B. WHERE OrderDate = CONVERT(datetime,@date)
C. WHERE OrderDate =@date
D. WHERE OrderDate = CAST(@date AS datetime)
2|Page

SQL Assessment | 30 Questions | 60 minutes


6. You work as a database developer in your company. You company has a SQL Server
database named SalesDB as illustrated in the following database diagram:

Company has retail stores in a few major cities across the country. The company
wants a list of Customers who live in a city that does not have a there store, along with
the customer's City. The result set must be sorted alphabetically by City name.
Which of the following Transact-SQL statements would return the required information?

A. SELECT CustomerName, CustomerCity


FROM Customers
WHERE CustomerCity NOT EXISTS (SELECT StoreCity FROM Stores) ORDER BY
CustomerCity

B. SELECT CustomerName, CustomerCity


FROM Customers
WHERE CustomerCity < > ALL (SELECT StoreCity FROM Stores) ORDER BY StoreCity

C. SELECT CustomerName, CustomerCity


FROM Customers
WHERE CustomerCity < > ANY (SELECT StoreCity FROM Stores)
ORDER BY CustomerCity

D. SELECT CustomerName, CustomerCity


FROM Customers
WHERE CustomerCity NOT IN (SELECT StoreCity FROM Stores)
ORDER BY StoreCity

3|Page

SQL Assessment | 30 Questions | 60 minutes


7. A SQL query automatically eliminates duplicates (True / False)?

A. TRUE
B. FALSE

8. Which of the following is a legal expression in SQL?

A. SELECT NULL FROM SALES;


B. SELECT NAME FROM SALES;
C. SELECT * FROM SALES WHEN PRICE = NULL;
D. SELECT # FROM SALES;

9. You work as a database developer. Your company has a SQL Server database named
SalesDB that has a table named Inventory.
The Inventory table has three columns named ProductID, InStore and InWarehouse. The
ProductID column is the primary key and is linked to the Products table.
The InStore column stores the quantity of a product that is held in company’s retail shop, while
the InWarehouse column stores the quantity of a product that is held at company’s
warehouse. You need to add a computed column that is the sum of values in the InStore and
InWarehoue columns for each product.
What Transact SQL statement would accomplish this task?

A. ALTER TABLE Inventory


ADD TotalProducts AS (InStore + InWarehouse)

B. ALTER TABLE Inventory


ADD TotalProducts int SPARSE NOT NULL

C. ALTER TABLE Inventory


ADD TotalProducts AS SUM (ALL) OVER (GROUP BY InStore, InWarehouse)

D. DROP TABLE Inventory


GO
CREATE TABLE Inventory
(
ProductID int NOT NULL PRIMARY KEY,
InStore int NOT NULL,
InWarehouse int NOT NULL,
TotalProducts AS SUM (InStore, InWarehouse)
)
10. Which of the following is true concerning a procedure?
A. You do not create them with SQL.

B. They do not need to have a unique name.

C. They include procedural and SQL statements.

4|Page

SQL Assessment | 30 Questions | 60 minutes

D. They are the same thing as a function.

11. Which of the following statements is true concerning routines and triggers?

A. Both consist of procedural code.

B. Both have to be called to operate.

C. Both run automatically.

D. Both are stored in the database.

12. The following SQL is which type of join: SELECT CUSTOMER_T. CUSTOMER_ID,
ORDER_T. CUSTOMER_ID, NAME, ORDER_ID FROM CUSTOMER_T,ORDER_T WHERE
CUSTOMER_T. CUSTOMER_ID = ORDER_T. CUSTOMER_ID

A. Equi-join

B. Natural join

C. Outer join

D. Cartesian join

13. You work as a SQL Server database developer. Your company has a database named
SalesDB with tables named Customer and Orders. The Customer and Orders tables were
created using the following Transact-SQL code:

CREATE TABLE SalesDB.Customers


(
CustomerID int NOT NULL PRIMARY KEY,
CustomerName nvarchar (250) NOT NULL,
Address1 nvarchar (100) NOT NULL,
Address2 nvarchar (100) NULL,
City nvarchar (50) NOT NULL,
State nvarchar (50) NOT NULL,
Zip varchar (5) NOT NULL,
Phone varchar (10) NOT NULL
)

CREATE TABLE SalesDB.Orders


(
OrderID int NOT NULL PRIMARY KEY,
CustomerID int NOT NULL,
OrderDate datetime NOT NULL,
ShipDate datetime NOT NULL,

5|Page

SQL Assessment | 30 Questions | 60 minutes


CustomerID int NOT NULL,
SalesRepID int NOT NULL
)
You are developing a stored procedure named OrdersByDate that returns the OrderID,
CustomerID, CustomerName and OrderDate.
The stored procedure will take a parameter named @date that uses the int datatype. The
@date parameter will be used to filter the result set based on the OrderDate column in
the Orders table. How would you create the stored procedure?

A. CREATE PROCEDURE OrdersByDate


@date int
AS
SELECT OrderID, CustomerID, CustormerName, OrderDate
FROM Orders INNER JOIN Customers ON Orders.CustomerId =
Customers.CustomerId WHERE OrderDate = CONVERT(datetime,@date)

B. CREATE PROCEDURE OrdersByDate


@date int
AS
SELECT OrderID, CustomerID, CustormerName, OrderDate
FROM Orders INNER JOIN Customers ON Orders.CustomerId =
Customers.CustomerId WHERE OrderDate =@date

C. CREATE PROCEDURE OrdersByDate


@date int
AS
SELECT OrderID, CustomerID, CustormerName, OrderDate
FROM Orders INNER JOIN Customers ON Orders.CustomerId =
Customers.CustomerId WHERE OrderDate = CAST(@date AS datetime)

D. CREATE PROCEDURE OrdersByDate


@date int
AS
SELECT OrderID, CustomerID, CustormerName, OrderDate
FROM Orders INNER JOIN Customers ON Orders.CustomerId =
Customers.CustomerId WHERE OrderDate = PARSE(@date AS datetime)

14. A UNION query is which of the following?


A. Combines the output from no more than two queries and must include the same
number of columns.

B. Combines the output from no more than two queries and does not include the same
number of columns.

C. Combines the output from multiple queries and must include the same number of

columns. D. Combines the output from multiple queries and does not include the same

number of columns.

6|Page

SQL Assessment | 30 Questions | 60 minutes

15. Which of the following is a correlated subquery?


A. Uses the result of an inner query to determine the processing of an outer

query. B. Uses the result of an outer query to determine the processing of an

inner query. C. Uses the result of an inner query to determine the processing

of an inner query. D. Uses the result of an outer query to determine the

processing of an outer query.

16. Which of the following is true concerning triggers?


A. You do not create them with SQL.

B. They execute against only some applications that access a

database. C. They have an event, condition, and action.

D. They cannot cascade (cause another trigger to fire).

17. When AUTOCOMMIT is set on, changes will be made automatically at the end of
each SQL statement.
A. True

B. False

18. In language constructs for procedures, PSM stands for

A. Permanent Storage Module


B. Persistent Storage Module
C. Prepared Statement Module
D. Prepared Storage Module

19. Construct that a recursive query should not use on recursive view, is

A. Aggregation
B. Unions
C. Comparisons
D. Booleans

7|Page

SQL Assessment | 30 Questions | 60 minutes


20. In cross-tab, number of columns are dependent on

A. Rows
B. Attributes
C. Relationship
D. Actual data

21. A query string can be constructed and prepared at runtime, using a statement of form

A. EXEC PREP
B. EXEC SQL PREPARE
C. SQL PREPARE
D. EXEC DEFINE PREPARE

22. For fixed-length types such as integer or float, maximum length field is

A. Accepted
B. Allotted
C. Ignored
D. Implemented

23. Which SQL keyword is used to retrieve only unique values?

A. Distinctive
B. Unique
C. Distinct
D. Different

24. Which SQL keyword is used to retrieve a maximum value?

A. Top
B. Most
C. Upper
D. Max

25. For triggers in SQL, statement that specifies a condition is said to be

A. While statement
B. From statement
C. Where statement

8|Page

SQL Assessment | 30 Questions | 60 minutes

D. When statement

26. To define a temporary view whose definition is available only to query in which it is
defined, clause used is

A. Declare clause
B. With clause
C. Define clause
D. While clause

27. Ranking operation is done with specification of

A. sort by
B. having by
C. order by
D. sequence by

28. Functions and procedures are defined with usage of SQL

A. Nonprocedural extension
B. Procedural extension
C. Structured extension
D. Nonstructured extension

29. What operator tests column for the absence of data?


A. EXIST Operator
B. NOT Operator
C. IS NULL Operator
D. None of Above

30. What is the meaning of LIKE '%0%0%'

A. Feature begins with two 0's


B. Feature ends with two 0's
C. Feature has more than two 0's
D. Feature has two 0's in it, at any position

9|Page

You might also like