SQL Server Questions and Answers – Basic SQL – 2

This set of SQL Server Multiple Choice Questions and Answers for freshers focuses on “Basic SQL – 2”.

1. What does DML stand for?
a) Different Mode Level
b) Data Model Language
c) Data Mode Lane
d) Data Manipulation language
View Answer

Answer: d
Explanation: Data Manipulation Language is used to modify the records in the database.

2. With SQL, how do you select all the records from a table named “Persons” where the value of the column “FirstName” ends with an “a”?
a) SELECT * FROM Persons WHERE FirstName=’a’
b) SELECT * FROM Persons WHERE FirstName LIKE ‘a%’
c) SELECT * FROM Persons WHERE FirstName LIKE ‘%a’
d) SELECT * FROM Persons WHERE FirstName=’%a%’
View Answer

Answer: c
Explanation: The SQL LIKE clause is used to compare a value to similar values using wildcard operators.

3. With SQL, how can you return all the records from a table named “Persons” sorted descending by “FirstName”?
a) SELECT * FROM Persons SORT BY ‘FirstName’ DESC
b) SELECT * FROM Persons ORDER FirstName DESC
c) SELECT * FROM Persons SORT ‘FirstName’ DESC
d) SELECT * FROM Persons ORDER BY FirstName DESC
View Answer

Answer: d
Explanation: The SQL SELECT statement queries data from tables in the database.
advertisement
advertisement

4. With SQL, how can you return the number of not null records in the “Persons” table?
a) SELECT COUNT() FROM Persons
b) SELECT COLUMNS() FROM Persons
c) SELECT COLUMNS(*) FROM Persons
d) SELECT COUNT(*) FROM Persons
View Answer

Answer: a
Explanation: COUNT(column_name) is used to count the number of rows of a table where column name is a column that does not allow NULL values.

5. What does the ALTER TABLE clause do?
a) The SQL ALTER TABLE clause modifies a table definition by altering, adding, or deleting table columns and/or constraints
b) The SQL ALTER TABLE clause is used to insert data into database table
c) THE SQL ALTER TABLE deletes data from database table
d) The SQL ALTER TABLE clause is used to delete a database table
View Answer

Answer: a
Explanation: The ALTER TABLE statement is used to add, delete, or modify columns.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. The UPDATE SQL clause can _____________
a) update only one row at a time
b) update more than one row at a time
c) delete more than one row at a time
d) delete only one row at a time
View Answer

Answer: b
Explanation: The SQL UPDATE Query is used to modify the existing records in a table. You can use WHERE clause with UPDATE query to update selected rows otherwise all the rows would be affected.

7. The UNION SQL clause can be used with _____________
a) SELECT clause only
b) DELETE and UPDATE clauses
c) UPDATE clause only
d) All of the mentioned
View Answer

Answer: a
Explanation: The SQL UNION operator is used to combine the result sets of 2 or more SELECT statements. It removes duplicate rows between the various SELECT statements.
advertisement

8. Which SQL statement is used to return only different values?
a) SELECT DIFFERENT
b) SELECT UNIQUE
c) SELECT DISTINCT
d) SELECT ALL
View Answer

Answer: c
Explanation: The SELECT DISTINCT statement is used to return only distinct (different) values.

9. Which SQL keyword is used to sort the result-set?
a) ORDER BY
b) SORT
c) ORDER
d) SORT BY
View Answer

Answer: a
Explanation: The ORDER BY keyword sorts the records in ascending order by default.
advertisement

10. How can you change “Hansen” into “Nilsen” in the “LastName” column in the Persons table?
a) UPDATE Persons SET LastName=’Hansen’ INTO LastName=’Nilsen’
b) MODIFY Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’
c) MODIFY Persons SET LastName=’Hansen’ INTO LastName=’Nilsen’
d) UPDATE Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’
View Answer

Answer: d
Explanation: In its simplest form, the syntax for the UPDATE statement when updating one table is:UPDATE table SET column1 = expression1,column2 = expression2,… WHERE conditions.

Sanfoundry Global Education & Learning Series – SQL Server.

To practice all areas of SQL Server for Freshers, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.