MSSQL Objective Questions and Answers for Professionals Set-2
1. In SQL Server, what is the purpose of the TRY...CATCH block?
Explanation: The TRY...CATCH block in SQL Server is used to handle exceptions and errors that may occur during the execution of T-SQL code.
2. Which of the following SQL Server views provides information about the columns, data types, and constraints in a database table?
Explanation: The sys.columns view in SQL Server provides information about the columns, data types, and constraints of a database table.
3. What is the purpose of the SQL Server function RANK()?
Explanation: The RANK() function in SQL Server is used to assign a rank to each row based on the specified column's ordering.
4. Which SQL Server system stored procedure is used to execute a dynamic SQL statement?
Explanation: The sp_executesql system stored procedure in SQL Server is used to execute a dynamic SQL statement.
5. Which SQL Server system view contains information about the execution plans of stored procedures?
Explanation: The sys.dm_exec_query_stats view in SQL Server contains information about the execution plans of stored procedures and other SQL queries.
6. In SQL Server, what is the purpose of the keyword "NOLOCK" in a SELECT statement?
Explanation: The "NOLOCK" hint in SQL Server allows a query to read uncommitted data, which may result in dirty reads.
7. Which SQL Server system view provides information about the active connections to the database?
Explanation: The sys.dm_exec_sessions view in SQL Server provides information about the active connections to the database.
8. What is the purpose of the SQL Server function CHOOSE()?
Explanation: The CHOOSE() function in SQL Server returns a value from a list of expressions based on an index.
9. In SQL Server, which of the following is used to handle NULL values in expressions?
Explanation: The COALESCE() function in SQL Server is used to handle NULL values in expressions by returning the first non-null expression from its arguments.
10. Which SQL Server system view provides information about the current locks on a database?
Explanation: The sys.dm_tran_locks view in SQL Server provides information about the current locks on a database.
11. What is the purpose of the SQL Server function STUFF()?
Explanation: The STUFF() function in SQL Server is used to replace a portion of a string with another substring.
12. What is the purpose of the SQL Server function PATINDEX()?
Explanation: The PATINDEX() function in SQL Server is used to return the starting position of a pattern in a string.
13. Which SQL Server system view provides information about the database files and their sizes?
Explanation: The sys.dm_db_file_space_usage view in SQL Server provides information about the database files and their sizes.
14. In SQL Server, what is the purpose of the keyword "CASCADE" in a FOREIGN KEY constraint?
Explanation: The "CASCADE" option in a FOREIGN KEY constraint in SQL Server is used to automatically delete or update related rows in child tables when the parent row is deleted or updated.
15. Which of the following SQL Server statements is used to change the data type of a column in a table?
Explanation: The ALTER TABLE statement in SQL Server is used to change the data type of a column in a table.
Rate Your Experience
: 89
: 1
Last updated in November, 2024
Quick Access