Batch Queries and System Catalogs in SQL Server - Quiz Explanation
The correct answers are indicated below, along with the text that explains the correct answers.
1.
What must you ensure that you do before issuing a query against a system catalog?
Please select the best answer.
A.
Switch to the appropriate database with the USE statement
B.
Install the system catalog
C.
Create a stored procedure to include the query against the system catalog
D.
Always switch to the MASTER database
The correct answer is A.
You must switch to the appropriate database before issuing your query. B is incorrect because you do not need to install the system catalog. It is installed when SQL Server is installed. C is incorrect because it is not necessary to create a stored procedure just to access a system catalog. D is incorrect because you do not always have to use the MASTER database, only if this is the database where the specific system table resides.
2.
What is the result of issuing this Transact-SQL batch?
DECLARE @tmp varchar(30) SELECT @tmp = ‘TMANN’ CREATE DEFAULT defPayGrade AS 5
Please select the best answer.
A.
The default will be created as indicated
B.
An error will occur because the default is not bound to a column
C.
An error will occur because CREATE DEFAULT is not the only statement in the batch
D.
An error will occur because the syntax is incorrect
The correct answer is C.
An error will occur because CREATE DEFAULT must be the only statement in a batch. A is incorrect because the default will not be created. B is incorrect because an error will not occur if the default is not bound to a column. D is incorrect because the syntax is correct.
3.
What is meta-data?
Please select the best answer.
A.
Data used to describe other objects contained within a database
B.
Data used to describe stored procedures only
C.
Data used to describe tables only
D.
Data that is described by meta-tags
The correct answer is A.
Meta-data is used to describe other database objects. B is incorrect because, although meta-data can describe stored procedures, they are not the only thing that meta-data describes. C is incorrect because although meta-data can describe tables, they are not the only thing that meta-data describes. D is incorrect because a meta-tag is not described by data.