Questions
What will be the correct output of following T-SQL statements ?
Q1.
1 2 3 4 5 |
SET LANGUAGE us_english; GO SELECT @@DATEFIRST; |
A. 1
B. 2
C. 3
D. 7
Q2.
1 2 3 |
DECLARE @value bigint = 123456789; SELECT FORMAT( @value, 'n', 'en-us'); |
A. $123456789.00
B. 123456789
C. $123,456,789.00
D. 123,456,789.00
Q3.
1 2 3 4 5 |
CREATE TABLE tbl_Test(Col1 int); SELECT PARSENAME('tbl_Test' , 1); DROP TABLE tbl_Test; |
A. 1
B. 0
C. tbl_Test
D. NULL
Q4.
1 2 3 |
DECLARE @month int =0; SELECT CHOOSE(@month,'Winter','Winter', 'Spring','Spring','Spring','Summer','Summer', 'Summer','Autumn','Autumn','Autumn','Winter'); |
A. NULL
B. Winter
C. Spring
D. Summer
Q5.
1 2 3 |
DECLARE @value int = 1, @datetime datetime2 = '2014-01-01'; SELECT DATEADD(year, @value, @datetime); |
A. 2015-01-01
B. 2015-01-02
C. 2015-01-01 00:00:00
D. 2015-01-01 00:00:00.0000000
Q6.
1 2 3 |
DECLARE @value bigint = 123456789; SELECT FORMAT( @value, 'n', 'en-gb'); |
A. £123,456,789.00
B. $123,456,789.00
C. 123,456,789.00
D. 123456789
Q7.
1 2 3 4 5 |
CREATE TABLE tbl_Test(Col1 int); SELECT PARSENAME('tbl_Test' , 2); DROP TABLE tbl_Test; |
A. 1
B. 0
C. tbl_Test
D. NULL
Q8.
1 2 3 |
DECLARE @month int =11; SELECT CHOOSE(@month,'Winter','Winter', 'Spring','Spring','Spring','Summer','Summer', 'Summer','Autumn','Autumn','Autumn','Winter'); |
A. NULL
B. Winter
C. Spring
D. Autumn
Q9.
1 2 3 |
DECLARE @value int = 1, @datetime datetime2 = '2014-01-01'; SELECT DATEADD(quarter, @value, @datetime); |
A. 2014-04-04
B. 2014-04-01
C. 2014-05-01 00:00:00
D. 2014-04-01 00:00:00.0000000
Q10.
1 2 3 |
DECLARE @date DATETIME = '01/30/2014'; SELECT FORMAT ( @date, 'MMMM dd, yyyy (dddd)', 'en-GB' ); |
A. 01/30/2014
B. 30/01/2014
C. 30/01/2014 00:00:00
D. January 30, 2014 (Thursday)
Answers
Q1. Correct Answer : D
@@DATEFIRST FUNCTION Returns the current value, for a session, of SET DATEFIRST. SET DATEFIRST specifies the first day of the week. The U.S. English default is 7, Sunday.
Q2. Correct Answer : D
FORMAT() function returns a value formatted with the specified format and optional culture in SQL Server 2012. Use the FORMAT function for locale-aware formatting of date/time and number values as strings. For general data type conversions, use CAST or CONVERT. – Syntax FORMAT ( value, format [, culture ] )
Q3. Correct Answer : C
PARSENAME() function returns the specified part of an object name. The parts of an object that can be retrieved are the object name, owner name, database name, and server name.
Q4. Correct Answer : A
CHOOSE() function returns the item at the specified index from a list of values.
Q5. Correct Answer : D
DATEADD() function returns a specified date with the specified number interval (signed integer) added to a specified datepart of that date.
Q6. Correct Answer : A
FORMAT() function returns a value formatted with the specified format and optional culture in SQL Server 2012. Use the FORMAT function for locale-aware formatting of date/time and number values as strings. For general data type conversions, use CAST or CONVERT. – Syntax FORMAT ( value, format [, culture ] )
Q7. Correct Answer : D
PARSENAME() function returns the specified part of an object name. The parts of an object that can be retrieved are the object name, owner name, database name, and server name.
Q8. Correct Answer : D
CHOOSE() function returns the item at the specified index from a list of values.
Q9. Correct Answer : D
DATEADD() function returns a specified date with the specified number interval (signed integer) added to a specified datepart of that date.
Q10. Correct Answer : D
FORMAT() function returns a value formatted with the specified format and optional culture in SQL Server 2012. Use the FORMAT function for locale-aware formatting of date/time and number values as strings. For general data type conversions, use CAST or CONVERT. – Syntax FORMAT ( value, format [, culture ] ).
Leave a Comment