Basic SQL Quiz - 2

Description: Basic SQL Quiz - 2
Number of Questions: 20
Created by:
Tags: sql
Attempted 0/20 Correct 0 Score 0
sql
  1. SELECT * FROM Persons WHERE FirstName LIKE 'Peter' AND LastName LIKE 'Jackson'

  2. SELECT * FROM Persons WHERE FirstName='Peter' AND LastName='Jackson'

  3. SELECT FirstName='Peter', LastName='Jackson' FROM Persons


Correct Option: B

With SQL, how do you select all the records from a table named "Persons" where the "LastName" is alphabetically between (and including) "Hansen" and "Pettersen"?

sql
  1. SELECT LastName>'Hansen' AND LastName

  2. SELECT * FROM Persons WHERE LastName BETWEEN 'Hansen' AND 'Pettersen'

  3. SELECT * FROM Persons WHERE LastName>'Hansen' AND LastName


Correct Option: B

Which SQL statement is used to return only different values?

sql
  1. SELECT UNIQUE

  2. SELECT INDENTITY

  3. SELECT DIFFERENT

  4. SELECT DISTINCT


Correct Option: D

Which SQL keyword is used to sort the result-set?

sql
  1. SORT BY

  2. ORDER

  3. ORDER BY

  4. SORT


Correct Option: C

With SQL, how can you return all the records from a table named "Persons" sorted descending by "FirstName"?

sql
  1. SELECT * FROM Persons SORT BY 'FirstName' DESC

  2. SELECT * FROM Persons ORDER BY FirstName DESC

  3. SELECT * FROM Persons ORDER FirstName DESC

  4. SELECT * FROM Persons SORT 'FirstName' DESC


Correct Option: B
sql
  1. INSERT INTO Persons VALUES ('Jimmy', 'Jackson')

  2. INSERT ('Jimmy', 'Jackson') INTO Persons

  3. INSERT VALUES ('Jimmy', 'Jackson') INTO Persons


Correct Option: A

With SQL, how can you insert "Olsen" as the "LastName" in the "Persons" table?

sql
  1. INSERT INTO Persons (LastName) VALUES ('Olsen')

  2. INSERT ('Olsen') INTO Persons (LastName)

  3. INSERT INTO Persons ('Olsen') INTO LastName


Correct Option: A

How can you change "Hansen" into "Nilsen" in the "LastName" column in the Persons table?

sql
  1. UPDATE Persons SET LastName='Hansen' INTO LastName='Nilsen'

  2. UPDATE Persons SET LastName='Nilsen' WHERE LastName='Hansen'

  3. MODIFY Persons SET LastName='Hansen' INTO LastName='Nilsen

  4. MODIFY Persons SET LastName='Nilsen' WHERE LastName='Hansen'


Correct Option: B

With SQL, how can you delete the records where the "FirstName" is "Peter" in the Persons Table?

sql
  1. DELETE FROM Persons WHERE FirstName = 'Peter'

  2. DELETE ROW FirstName='Peter' FROM Persons

  3. DELETE FirstName='Peter' FROM Persons


Correct Option: A

With SQL, how can you return the number of records in the "Persons" table?

sql
  1. SELECT COLUMNS() FROM Persons

  2. SELECT COUNT(*) FROM Persons

  3. SELECT COLUMNS(*) FROM Persons

  4. SELECT COUNT() FROM Persons


Correct Option: B

What will be the output of the following statement? SELECT LEN(CAST(LEFT('026-100', 3) AS INT))

sql
  1. 2

  2. 3

  3. 7

  4. Statement will generate an error.


Correct Option: A

What will be the output of the following statement? SELECT CAST(-1 AS SMALLDATETIME)

sql
  1. 1900-01-01 00:00:00.000

  2. 1899-01-01 00:00:00.000

  3. 1752-01-01 00:00:00.000

  4. The system will generate an error. Only positive integer values can be converted to a SMALLDATETIME data type.


Correct Option: D

What will be the output of the following statement? SELECT STR(6365, 3)

sql

  1. 6365

  2. 6,365

  3. 6400

  4. 6365.000


Correct Option: A

What will be the output of the following statement? SET ARITHABORT OFF SET ANSI_WARNINGS OFF SELECT 100/0

sql
  1. Null

  2. 0

  3. Infinity

  4. An error is generated.


Correct Option: A

View text definitions are stored in which system table?

sql
  1. sysobjects

  2. syscolumns

  3. syscomments

  4. sysviews


Correct Option: C

What's the maximum value can an INT data type hold?

sql
  1. 2,147,483,647

  2. 2,147,483,648

  3. 4,294,967,295

  4. 4,294,967,296


Correct Option: A

Which of the following is NOT a valid description of the public role?

sql
  1. The public role captures all default permissions for users in a database.

  2. The public role cannot be dropped.

  3. The public role is contained in every database, including msdb, tempdb, model, and all user databases except in the master database for security purposes.

  4. The public role cannot have users, groups, or roles assigned to it.


Correct Option: C

What is the maximum date value that can be stored in a SMALLDATETIME data type?

sql
  1. June 6, 2079

  2. July 6, 2079

  3. December 31, 2079

  4. December 31, 9999


Correct Option: A
- Hide questions