Questions
What will be the correct output of following T-SQL statements?
Q1.
1 2 3 |
DECLARE @startdate datetime2 = '2014-01-01', @enddate datetime2 = '2014-01-03'; SELECT DATEDIFF(hour, @startdate, @enddate); |
A. 24
B. 36
C. 47
D. 48
Q2.
1 2 3 |
DECLARE @expression varchar(100)='Querying SQL Server 2012 - 1000 Exam questions and answers'; SELECT PATINDEX('%[0-9]%' , @expression); |
A. 0
B. 1
C. 21
D. 2012
Q3.
1 2 3 4 5 6 7 |
CREATE TABLE tbl_Test(Col1 int IDENTITY(2,5),Col2 varchar(20)); INSERT tbl_Test VALUES ('Cricket'),('Rugby'); SELECT IDENT_SEED('tbl_Test'); DROP TABLE tbl_Test; |
A. 1
B. 2
C. 5
D. 10
Q4.
1 2 3 |
DECLARE @year int=2014, @month int=3, @day int=16; SELECT DATEFROMPARTS( @year, @month, @day ); |
A.15/03/2014
B. 16/03/2014
C. 16/03/2014 00:00:00
D. 16/01/2014 00:00:00
Q5.
1 2 3 |
DECLARE @expression varchar(100)='Querying SQL Server 2012 - 1000 Exam questions and answers'; SELECT PATINDEX('%g_s%' , @expression); |
A. 0
B. 1
C. g
D. 8
Q6.
1 2 3 |
DECLARE @value datetime2 = '2014-06-01'; SELECT DATENAME(year, @value) ; |
A. 2014
B. 01/06/2014
C. 01/06/2014 00:00:00
D. 00:00:00
Q7.
1 2 3 |
DECLARE @expression varchar(100)='Querying SQL Server 2012'; SELECT QUOTENAME(@expression); |
A. Querying SQL Server 2012
B. QueryingSQLServer2012
C. [Querying SQL Server 2012]
D. [QueryingSQLServer2012]
Q8.
1 2 3 |
DECLARE @value datetime2 = '2014-06-01'; SELECT DATENAME(month, @value); |
A. 2014
B. 01/06/2014
C. 6
D. June
Q9.
1 2 3 |
DECLARE @expression varchar(100)='Querying SQL Server 2012'; SELECT QUOTENAME(@expression,'"' ); |
A. Querying SQL Server 2012
B. QueryingSQLServer2012
C. [Querying SQL Server 2012]
D. Querying SQL Server 2012
Q10.
1 2 3 |
DECLARE @value datetime2 = '2014-02-01'; SELECT DATENAME(dayofyear, @value); |
A. 30
B. 31
C. 32
D. 1
Answers
Q1. Correct Answer : D
DATEDIFF() function returns the count (signed integer) of the specified datepart boundaries crossed between the specified startdate and enddate.
Q2. Correct Answer : C
PATINDEX() function returns the starting position of the first occurrence of a pattern in a specified expression, or zeros if the pattern is not found, on all valid text and character data types
Q3. Correct Answer : B
IDENT_SEED() function returns the original seed value that was specified when an identity column in a table or a view was created.
Q4. Correct Answer : B
DATEFROMPARTS() function returns a date value for the specified year, month, and day.
Q5. Correct Answer : D
PATINDEX() function returns the starting position of the first occurrence of a pattern in a specified expression, or zeros if the pattern is not found, on all valid text and character data types
Q6. Correct Answer : A
DATENAME() function returns a character string that represents the specified datepart of the specified date
Q7. Correct Answer : C
QUOTENAME() function returns a Unicode string with the delimiters added to make the input string a valid SQL Server delimited identifier.
Q8. Correct Answer : D
DATENAME() function returns a character string that represents the specified datepart of the specified date
Q9. Correct Answer : D
QUOTENAME() function returns a Unicode string with the delimiters added to make the input string a valid SQL Server delimited identifier.
Q10. Correct Answer : C
DATENAME() function returns a character string that represents the specified datepart of the specified date
Leave a Comment