This set of SQL Server Multiple Choice Questions & Answers (MCQs) focuses on “Variables”.
1. Variables was added newly to SQL Server version _____________
a) 2005
b) 2008
c) 2012
d) 2014
View Answer
Explanation: Variable feature was introduced in SQL Server 2008.
2. Point out the wrong statement.
a) All the global variables represent information specific to the server or a current user session
b) SQL Server provides only three global variables
c) Global variables represent a special type of variable
d) None of the mentioned
View Answer
Explanation: SQL Server provides a massive number of global variables, which are very effective to use in our regular Transact-SQL.
3. Which of the following keyword is not associated with initialization of variable?
a) DECLARE
b) SET
c) SELECT
d) All of the mentioned
View Answer
Explanation: Variables are declared in the body of a batch or procedure with the DECLARE statement and are assigned values by using either a SET or SELECT statement.
4. Which of the following is a global variable?
a) @@CPU_BUSY
b) @@CPU_IO
c) @@CPU
d) @@I_BUSY
View Answer
Explanation: @@CPU_BUSY denotes the amount of time, in ticks, that the CPU has spent doing SQL Server work since the last time SQL Server was started.
5. Point out the right statement.
a) The server always maintain the values of local variable
b) Local variable names begin with a @@ prefix
c) T-SQL restricts the use of variables in ways that aren’t common in other development environments
d) None of the mentioned
View Answer
Explanation: T-SQL supports variables, as do most other development environments.
6. Which of the following global has return type ‘numeric’?
a) @@ERROR
b) @@MAX_CONNECTIONS
c) @@CPU_BUSY
d) @@IDENTITY
View Answer
Explanation: @@identity retains the last value inserted into an IDENTITY column, even if the statement that inserted it fails to commit.
7. Value of the @techonthenet variable can be changed using the SET statement, as follows __________
DECLARE @techonthenet VARCHAR(50);
a) SET @techonthenet = ‘Example showing how to declare variable’;
b) SELECT @techonthenet = ‘Example showing how to declare variable’;
c) SET @techonthenet == ‘Example showing how to declare variable’;
d) None of the mentioned
View Answer
Explanation: SET keyword sets the specified local variable, previously created by using the DECLARE.
8. _________ gives amount of time, in ticks, that SQL Server has been idle since it was last started.
a) @@ERROR
b) @@IDLE
c) @@LANGID
d) @@LANGUAGE
View Answer
Explanation: Return type of @@IDLE is int.
9. What will be the output of the following code?
SELECT @@IO_BUSY*@@TIMETICKS AS 'IO microseconds', GETDATE() AS 'as of'
a)
IO microseconds AS OF --------------- ----------------------- 590 2009-08-19 22:09:44.013
b)
IO microseconds AS OF --------------- ----------------------- 5906250 2009-08-19 22:09:44.013
c)
IO microseconds AS OF --------------- ----------------------- 59250 2009-08-19 22:09:44.013
d) None of the mentioned
View Answer
Explanation: @@IO_BUSY gives amount of time, in ticks, that SQL Server has spent doing input and output operations since it was last started. Return type is an integer.
10. @@LANGUAGE variable whose return type nvarchar is specified in _____________
a) sys.name
b) syslang.name
c) syslanguages.name
d) syslanguages.id
View Answer
Explanation: The name of the language currently in use is specified in syslanguages.name.
Sanfoundry Global Education & Learning Series – SQL Server.
To practice all areas of SQL Server, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Practice Programming MCQs
- Check SQL Server Books
- Check Information Technology Books
- Apply for Programming Internship