Questions
What will be the correct output of following T-SQL statements?
Q1.
1 2 3 4 5 |
DECLARE @ToFind varchar(50)='0'; DECLARE @ToSearch varchar(100)='Querying SQL Server 2012 - 1000 Exam questions and answers'; SELECT CHARINDEX(@ToFind, @ToSearch,25); |
A. NULL
B. 29
C. 22
D. 0
Q2.
1 2 3 4 5 |
CREATE TABLE tbl_Test(Col1 int); SELECT DISTINCT OBJECTPROPERTY(OBJECT_ID('tbl_Test'),'IsView'); DROP TABLE tbl_Test; |
A. 1
B. Fales
C. 0
D. NULL
Q3.
1 2 3 4 5 6 7 8 9 10 11 |
DECLARE @value sql_variant='69999.999'; SELECT CASE WHEN TRY_CONVERT(numeric(10,5),@value) IS NULL THEN 'Cast failed' ELSE TRY_CONVERT(numeric(10,5),@value) END; |
A. 0.999
B. 69999
C. 69999.999
D. Cast failed
Q4.
1 2 3 4 5 6 7 8 9 |
DECLARE @value nvarchar(10)='2014-01-01'; SELECT CASE WHEN TRY_PARSE(@value AS datetimeoffset USING 'en-GB') IS NULL THEN 'Cast failed' ELSE TRY_PARSE(@value AS datetimeoffset USING 'en-GB') END; |
A. Cast failed
B. 01/01/2014
C. 2014-01-01 00:00:00.0000000 +00:00
D. 01/01/2014 00:00:00
Q5.
1 2 3 4 5 |
DECLARE @string_value1 varchar(50)='Querying SQL Server 2012'; DECLARE @string_value2 varchar(50)='1000 Exam questions and answers'; SELECT CONCAT(@string_value1 ,' - ', @string_value2); |
A. NULL
B. Querying SQL Server 2012 – 1000 Exam questions and answers
C. Querying SQL Server 20121000 Exam questions and answers
D. Querying SQL Server 2012
Q6.
1 2 3 4 5 |
CREATE TABLE tbl_Test(Col1 int); SELECT DISTINCT OBJECTPROPERTY(OBJECT_ID('tbl_Test'),'TableHasClustIndex'); DROP TABLE tbl_Test; |
A. 1
B. Fales
C. 0
D. NULL
Q7.
1 2 3 4 5 6 7 8 9 |
DECLARE @value nvarchar(10)='69999'; SELECT CASE WHEN TRY_PARSE(@value AS int USING 'en-US') IS NULL THEN 'Cast failed' ELSE TRY_PARSE(@value AS int USING 'en-US') END; |
A. 69999
B. NULL
C. 69999.00
D. Cast failed
Q8.
1 2 3 4 5 |
DECLARE @string_value1 varchar(50)='Querying SQL Server 2012'; DECLARE @string_value2 varchar(50)=null; SELECT CONCAT(@string_value1 ,' - ', @string_value2); |
A. NULL
B. Querying SQL Server 2012 – 1000 Exam questions and answers
C. Querying SQL Server 2012 –
D. Querying SQL Server 2012
Q9.
1 2 3 4 5 |
CREATE TABLE tbl_Test(Col1 int); SELECT DISTINCT OBJECTPROPERTY(OBJECT_ID('tbl_Test'),'TableHasIdentity'); DROP TABLE tbl_Test; |
A. 1
B. 0
C. TRUE
D. NULL
Q10.
1 2 3 4 5 6 7 8 9 |
DECLARE @value nvarchar(10)='69999'; SELECT CASE WHEN TRY_PARSE(@value AS decimal(10,4) USING 'en-US') IS NULL THEN 'Cast failed' ELSE TRY_PARSE(@value AS decimal(10,4) USING 'en-US') END; |
A. 69999
B. NULL
C. 69999.0000
D. Cast failed
Answers
Q1. Correct Answer : B
CHARINDEX() function Searches an expression for another expression and returns its starting position if found. Eg:- CHARINDEX ( expressionToFind ,expressionToSearch [ , start_location ] )
Q2. Correct Answer : C
OBJECTPROPERTY() function returns information about schema-scoped objects in the current database.
Q3. Correct Answer : C
TRY_CONVERT() function returns a value cast to the specified data type if the cast succeeds; otherwise, returns null.
Q4. Correct Answer : C
TRY_PARSE() function returns the result of an expression, translated to the requested data type, or null if the cast fails in SQL Server. Use TRY_PARSE only for converting from string to date/time and number types.
Q5. Correct Answer : B
CONCAT() function returns a string that is the result of concatenating two or more string values. Syntax : CONCAT ( string_value1, string_value2 [, string_valueN ] )
Q6. Correct Answer : C
OBJECTPROPERTY() function returns information about schema-scoped objects in the current database.
Q7. Correct Answer : A
TRY_PARSE() function returns the result of an expression, translated to the requested data type, or null if the cast fails in SQL Server. Use TRY_PARSE only for converting from string to date/time and number types.
Q8. Correct Answer : C
CONCAT() function returns a string that is the result of concatenating two or more string values. Syntax : CONCAT ( string_value1, string_value2 [, string_valueN ] )
Q9. Correct Answer : B
OBJECTPROPERTY() function returns information about schema-scoped objects in the current database.
Q10. Correct Answer : C
TRY_PARSE() function returns the result of an expression, translated to the requested data type, or null if the cast fails in SQL Server. Use TRY_PARSE only for converting from string to date/time and number types.
Leave a Comment