Transact-SQL (T-SQL) MCQs

Transact-SQL (T-SQL) MCQs

Our experts have gathered these Transact-SQL (T-SQL) MCQs through research, and we hope that you will be able to see how much knowledge base you have for the subject of Transact-SQL (T-SQL) by answering these 20 multiple-choice questions.
Get started now by scrolling down!

1: Which answer is NOT a type of table index?

A.   Nonclustered

B.   Unique

C.   Heap

D.   Hash

2: The keywords AND, IN, LIKE, and between all belong to a category called what?

A.   Joining operations

B.   Linking operations

C.   Criteria operations

D.   Logical operations

3: What is an example of a DDL command in SQL?

A.   TRUNCATE TABLE

B.   DELETE

C.   MERGE

D.   DROP

4: You need to write a query that returns all Employees that have a LastName starting with the letter A. Which WHERE clause should you use to fill in the blank in this query?

A.   WHERE LastName = A*

B.   WHERE LastName = LIKE '%A%'

C.   WHERE LastName LIKE 'A%'

D.   WHERE LastName IN ('A*')

5: Which query shows the first name, department, and team of all students with the two lowest points?

A.   SELECT LIMIT(2) first_name, department, team FROM Students ORDER BY points ASC;

B.   SELECT TOP(2) first_name, deprtment, team FROM Students ORDER BY points DESC;

C.   SELECT TOP(2) WITH TIES first_name, department, team FROM Students ORDER BY points;

D.   SELECT BOTTOM(2) first_name, department, team FROM Students ORDER BY points ASC;

6: What is the result of this statement?

A.   SELECT FLOOR(-1234.321)

B.   -1234.3

C.   -1234

D.   -1235

E.   1234.321

7: Which is the best approach to update the last name of the student Donette Figgins to Smith

A.   UPDATE Students SET last_name = 'Smith' WHERE email = 'dfiggins@rouxacademy.com';

B.   UPDATE Students SET last_name = 'Figgins' WHERE email = 'dfiggins@rouxacademy.com';

C.   UPDATE Students SET last_name = 'Figgins' WHERE last_name = 'Smith' AND first-name = 'Donette';

D.   UPDATE Students SET last_name = 'Smith' WHERE last_name = 'Figgins' AND first-name = 'Donette';

8: Which of these data types is an approximate numeric?

A.   Real

B.   Bit

C.   Decimal

D.   Numeric

9: You need to remove all data from a table name Products. Which query fully logs the removal of each record?

A.   TRUNCATE FROM Products *;

B.   DELETE FROM Products;

C.   DELETE * FROM Products;

D.   TRUNCATE TABLE Products;

10: What is the result of this query? SELECT 1 / 2 AS Result;

A.   0

B.   0.5

C.   Error

D.   2

11: Which data type will most efficiently store a person's age in years?

A.   Float

B.   Int

C.   Tinyint

D.   Bigint

12: What is the result of this query? SELECT 'abc\ def' AS Result;

A.   abc\def

B.   abcdef

C.   error

D.   abc def

13: To select a random student from the table, which statement could you use?

A.   SELECT TOP(1) first_name, last_name FROM Students ORDER BY NEWID();

B.   SELECT TOP(1) RAND(first_name, last_name) FROM Student;

C.   SELECT TOP(1) first_name, last_name FROM Student;

D.   SELECT TOP(1) first_name, last_name FROM RAND(Student);

14: Which statement creates a new database schema named Sales and establish Sharon as the owner?

A.   ALTER USER Sharon WITH DEFAULT_SCHEMA = Sales;

B.   ALTER USER Sharon SET SCHEMA Sales;

C.   CREATE SCHEMA Sales SET OWNER Sharon;

D.   CREATE SCHEMA Sales AUTHORIZATION Sharon;

15: The result of a CROSS JOIN between a table with 4 rows, and one with 5 rows, will give with _ rows.

A.   1024

B.   20

C.   9

16: You need to write a query that returns all products that have a SerialNumber ending with "10_3". Which WHERE clause should you use to fill in the blank in this query?SELECT ProductID, ProductName, SerialNumber FROM Products______ ;

A.   WHERE SerialNumer LIKE '%10_3'

B.   WHERE SerialNumer LIKE ('%10'+'_'+'3')

C.   WHERE SerialNumer LIKE '%10

D.   WHERE SerialNumer LIKE '%10[_]3'

17: When no join type between multiple tables in a query's FROM clause is specified, what type of join is assumed?

A.   INNER

B.   RIGHT

C.   LEFT

D.   FULL

18: How many bytes of storage does the int data type consume?

A.   1 byte

B.   2 bytes

C.   4 bytes

D.   8 bytes

19: What does a RIGHT JOIN ensure?

A.   That only records from the rightmost table will be displayed

B.   That no records from the rightmost table are displayed if the records dont have corresponding records in the left table

C.   That records from the rightmost table will be displayed only if the records have a corresponding value in the leftmost table

D.   That all records from the rightmost table are represented in the result, even if there are no corresponding records in the left table

20: Given a table with the following structure, which query returns all student names with the highest grade? CREATE TABLE Students (StudentName varchar(50),Grade int );

A.   SELECT StudentName FROM Students WHERE Grade = MAX(Grade);

B.   SELECT TOP(1) StudentName FROM Students ORDER BY Grade;

C.   SELECT TOP(1) WITH TIES StudentName FROM Students ORDER BY Grade DESC;

D.   SELECT StudentName, MAX(Grade) FROM Students ORDER BY Grade DESC;

21: What is the result of an INNER JOIN between table1 and table2?

A.   Only records that have corresponding entries in table1 and table2 are displayed.

B.   No records from table1 are ever displayed.

C.   All records from table1 are displayed, regardless of whether the records have a corresponding row in table2

D.   Only records that have no corresponding records in table1 or table2 are displayed.

22: To remove all of the content from the Students table but keep the schema, which statement should you use?

A.   TRUNCATE TABLE Students;

B.   TRUNCATE * FROM Students;

C.   DROP TABLE Students;

D.   REMOVE * FROM Students;

23: You would like to have a record added to a TableB every time a record is modified in TableA. What technique should you look at implementing?

A.   You should create a DML trigger on the server.

B.   You should create a DDL trigger on the database.

C.   You should create a DML trigger on TableA.

D.   You should create a DML trigger on TableB.

24: What is the result of this query? SELECT 123+'123' AS Result;

A.   Error

B.   '123''123'

C.   123123

D.   246

25: To combine the results of two or more SELECT statements, removing duplicates, which keyword can you use?

A.   DEDUPE

B.   SELECT

C.   MERGE

D.   UNION

26: Your database currently has a table called Inventory in the Warehouse schema. You need to move the table to the Products schema. Which query accomplishes this goal?

A.   ALTER SCHEMA Products TRANSFER Warehouse.Inventory;

B.   ALTER TABLE Warehouse.Inventory TRANSFER Products.Inventory;

C.   ALTER TABLE Warehouse.Inventory ADD SCHEMA Products;

D.   ALTER SCHEMA Warehouse ADD TABLE Inventory;

27: You need to create a simple database backup in the server's Z:\Backups directory. Which query should you use?

A.   BACKUP MyDatabase TO LOCATION = 'Z:\Backups\MyDatabase.bak';

B.   CREATE BACKUP (DATABASE = 'MyDatabase' TO DISK = 'Z:\Backups\MyDatabase. bak');

C.   BACKUP DATABASE MyDatabase ON 'Z:\Backups\MyDatabase.bak';

D.   BACKUP DATABASE MyDatabase TO DISK = 'z:\Backups\MyDatabase.bak';

28: Though not currently a requirement, what will a future release of SQL Server require of all SQL statements?Though not currently a requirement, what will a future release of SQL Server require of all SQL statements?

A.   All statements must end with a semicolon.

B.   All statements must operate on a table of data.

C.   All statements must always be written in uppercase letters.

D.   All statements must include more than one variable.

29: Which is the best approach to update the last name and email address of a student with ID 56295?

A.   UPDATE Students SET last_name='Smith', email = 'dsmith@rouxacademy.com' WHERE id='56295';

B.   UPDATE Students SET last_name='Smith', email = 'dsmith@rouxacademy.com' WHERE id=56295;

C.   UPDATE Students SET last_name='Smith' AND email = 'dsmith@rouxacademy.com' WHERE id=56295;

D.   UPDATE Students SET last_name='Smith' AND email = 'dsmith@rouxacademy.com' WHERE id='56295';