Questions
What will be the correct output of following T-SQL statements?
Q1.
1 2 |
DECLARE @startdate datetime2 = '2014-01-01', @enddate datetime2 = '2014-05-01'; SELECT DATEDIFF(quarter, @startdate, @enddate); |
A. 0
B. 1
C. -1
D. 1.33
Q2.
1 2 3 |
DECLARE @pattern nvarchar(50)='q'; DECLARE @expression varchar(100)='Querying SQL Server 2012 - 1000 Exam questions and answers'; SELECT PATINDEX('%'+ @pattern +'%' , @expression COLLATE Latin1_General_CS_AS); |
A. 0
B. 1
C. Q
D. 38
Q3.
1 2 3 4 5 |
CREATE TABLE tbl_Test(Col1 int IDENTITY(1,10),Col2 varchar(20)); INSERT tbl_Test VALUES ('Football'),('Cricket'),('Rugby'); SELECT IDENT_INCR('tbl_Test'); DROP TABLE tbl_Test; |
A. 1
B. 2
C. 3
D. 10
Q4.
1 2 |
DECLARE @startdate datetime2 = '2014-01-01', @enddate datetime2 = '2014-01-03'; SELECT DATEDIFF(hour, @startdate, @enddate); |
A. 24
B. 36
C. 47
D. 48
Q5.
1 2 |
DECLARE @startdate datetime2 = '2014-01-01', @enddate datetime2 = '2014-06-25'; SELECT DATEDIFF(month, @startdate, @enddate); |
A. 5
B. 5.5
C. 6
D. 6.5
Q6.
1 2 3 |
DECLARE @pattern nvarchar(50)='q'; DECLARE @expression varchar(100)='Querying SQL Server 2012 - 1000 Exam questions and answers'; SELECT PATINDEX('%'+ @pattern +'_u%' , @expression COLLATE Latin1_General_CS_AS); |
A. 0
B. 1
C. Q
D. 38
Q7.
1 2 3 4 5 |
CREATE TABLE tbl_Test(Col1 int IDENTITY(10,5),Col2 varchar(20)); INSERT tbl_Test VALUES ('Football'),('Cricket'),('Rugby'); SELECT IDENT_INCR('tbl_Test'); DROP TABLE tbl_Test; |
A. 1
B. 2
C. 5
D. 10
Q8.
1 2 |
DECLARE @startdate datetime2 = '2014-01-01', @enddate datetime2 = '2014-01-03'; SELECT DATEDIFF(hour, @startdate, @enddate); |
A. 24
B. 36
C. 47
D. 48
Q9.
1 2 |
DECLARE @startdate datetime2 = '2014-01-01', @enddate datetime2 = '2014-01-25'; SELECT DATEDIFF(week, @startdate, @enddate); |
A. 1
B. 2
C. 3
D. 3.15
Q10.
1 2 |
DECLARE @expression varchar(100)='Querying SQL Server 2012 - 1000 Exam questions and answers'; SELECT PATINDEX('%S[^Q]%' , @expression); |
A. 0
B. 10
C. SQL
D. 14
Answers
Q1. Correct Answer : B
Hint : DATEDIFF() function returns the count (signed integer) of the specified datepart boundaries crossed between the specified startdate and enddate.
Q2. Correct Answer : D
Hint : 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 : D
Hint : IDENT_INCR() function returns the increment value specified during the creation of an identity column in a table or view that has an identity column.
Q4. Correct Answer : D
Hint : DATEDIFF() function returns the count (signed integer) of the specified datepart boundaries crossed between the specified startdate and enddate.
Q5. Correct Answer : A
Hint : DATEDIFF() function returns the count (signed integer) of the specified datepart boundaries crossed between the specified startdate and enddate.
Q6. Correct Answer : A
Hint : 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.
Q7. Correct Answer : C
Hint : IDENT_INCR() function returns the increment value specified during the creation of an identity column in a table or view that has an identity column.
Q8. Correct Answer : D
Hint : DATEDIFF() function returns the count (signed integer) of the specified datepart boundaries crossed between the specified startdate and enddate.
Q9. Correct Answer : C
Hint : DATEDIFF() function returns the count (signed integer) of the specified datepart boundaries crossed between the specified startdate and enddate.
Q10. Correct Answer : D
Hint : 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.
Leave a Comment