Questions
What will be the correct output of following T-SQL statements?
Q1.
1 |
SELECT ROUND(199.0099, 3, 0); |
A. 199.0099
B. 199
C. 199.01
D. 199.0009
Q2.
1 2 3 |
CREATE TABLE tbl_Test(Col1 varchar(20)); SELECT COL_LENGTH('tbl_Test','Col1'); DROP TABLE tbl_Test; |
A. 10
B. 20
C. 40
D. 8
Q3.
1 |
SELECT 1/CEILING(-0.46); |
A. 0
B. -1
C. 0.5
D. Divide by zero error encountered.
Q4.
1 2 3 |
DECLARE @URL VARCHAR(1000); SET @URL = 'http://www.bbc.co.uk/sport/0/cricket/'; SELECT SUBSTRING(@URL, PATINDEX('%www%',@URL), 20); |
A. www.bbc.co.uk/sport/0/cricket/
B. bbc.co.uk
C. www.bbc.co.uk
D. www.bbc.co.uk/sport/
Q5.
1 |
SELECT TYPEPROPERTY('geometry','AllowsNull'); |
A. geometry
B. FALSE
C. 0
D. 1
Q6.
1 |
SELECT ABS(-1)-ABS(-1); |
A. 0
B. -1
C. 1
D. 2
Q7.
1 2 3 4 |
DECLARE @expression varchar(100)='SQL Server 2012 - 1000 Exam questions and answers'; DECLARE @replaceWith varchar(100)='Windows';DECLARE @start int=1; DECLARE @length int=15; SELECT STUFF(@expression,@start,@length,@replaceWith); |
A. SQL Server 2012 – 1000 Exam questions and answers
B. Windows – 1000 Exam questions and answers
C. SQL Server 2012
D. Windows Server 2012 – 1000 Exam questions and answers
Q8.
1 |
SELECT TYPEPROPERTY('money','Scale'); |
A. money
B. 8 bytes
C. 2
D. 4
Q9.
1 |
SELECT RAND(); |
A. 0.715436657
B. 1.182458909
C. 1
D. -1
Q10.
1 2 3 4 |
DECLARE @value datetime='2014-07-21 17:02:58.403'; SELECT CASE WHEN TRY_CAST(@value AS datetime2) IS NULL THEN 'Cast Failed' ELSE TRY_CAST(@value AS datetime2) END; |
A. Cast Failed
B. 21/07/2014 17:02:58
C. 21/07/2014 17:02:58.4030000
D. 21/07/2014
Answers
Q1. Correct Answer : C
Hint : ROUND() mathematical function returns a numeric value, rounded to the specified length or precision.
Q2. Correct Answer : B
Hint : COL_LENGTH() function returns the defined length, in bytes, of a column.
Q3. Correct Answer : D
Hint : CEILING() mathematical function returns the smallest integer greater than, or equal to, the specified numeric expression.
Q4. Correct Answer : D
Hint : SUBSTRING() function returns part of a character, binary, text, or image expression.
Q5. Correct Answer : D
Hint : TYPEPROPERTY() function returns information about a data type.
Q6. Correct Answer : A
Hint : ABS() mathematical function that returns the absolute (positive) value of the specified numeric expression.
Q7. Correct Answer : B
Hint : STUFF() function inserts a string into another string. It deletes a specified length of characters in the first string at the start position and then inserts the second string into the first string at the start position.
Q8. Correct Answer : D
Hint : TYPEPROPERTY() function returns information about a data type.
Q9. Correct Answer : A
Hint : RAND() mathematical function returns a pseudo-random float value from 0 through 1, exclusive.
Q10. Correct Answer : C
Hint : TRY_CAST() function returns a value cast to the specified data type if the cast succeeds; otherwise, returns null.
Leave a Comment