Home ยป SQL SERVER Interview Q & A QUIZ on SUBSTRING()

SQL SERVER Interview Q & A QUIZ on SUBSTRING()

Q 1 >ย 

DECLARE @stringtxt as varchar(20)
SET @stringtxt=‘Microsoft SQL SERVER’

SELECT SUBSTRING( @stringtxt , 11 ,3) as output

1> ‘Microsoft’

2> ‘SQL’

3> BLANK

4> Invalid Substring statement

Answer

2> ‘SQL’

 

Q 2 >ย 

DECLARE @stringtxt as varchar(20)
SET @stringtxt=‘Microsoft SQL SERVER’

SELECT SUBSTRING( @stringtxt , 11 ,0) as output

1> ‘Microsoft’

2> ‘SQL’

3> BLANK

4> ‘SQL SERVER’

Answer

2> BLANK

 

 

Q 3 >ย 

DECLARE @stringtxt as varchar(20)
SET @stringtxt=‘Microsoft SQL SERVER’

SELECT SUBSTRING( @stringtxt , -1 ,9) as output

1> ‘Microso’

2> ‘SQL’

3> BLANK

4> ‘SQL SERVER’

Answer

1> ‘Microso’

 

Q 4 >ย 

DECLARE @stringtxt as varchar(20)
SET @stringtxt=‘Microsoft SQL SERVER’

SELECT SUBSTRING( @stringtxt , 1 ,9) as output

1> ‘Microsoft’

2> ‘Microsof’

3> BLANK

4> ‘SQL SERVER’

Answer

1> ‘Microsoft’

 

 

Q 5 >ย 

DECLARE @stringtxt as varchar(20)
SET @stringtxt=‘Microsoft SQL SERVER’

SELECT ‘SQL ‘ + SUBSTRING( @stringtxt , 15 ,6) as output

1> ‘SQLย  SQL SERVER’

2> ‘SQL SER’

3> BLANK

4> ‘SQL SERVER’

Answer

4> ‘SQL SERVER’

 

 

Q 6 >ย 

DECLARE @stringtxt as varchar(20)
SET @stringtxt=‘Microsoft SQL SERVER’

SELECT SUBSTRING( @stringtxt +‘ SQL’ , 15 ,6) as output

1> ‘SQL SER’

2> ‘SQL SERVER’

3> BLANK

4> ‘SERVER’

Answer

4> ‘SERVER’

 

 

Q 7 >ย 

DECLARE @stringtxt as varchar(20)
SET @stringtxt=‘Microsoft SQL SERVER’

SELECT SUBSTRING( @stringtxt , 11 ,Len(@stringtxt)-10) as output

1> ‘Microsoft SQL SERVER’

2> ‘SQL SERVER’

3> ‘Microsoft’

4> Invalid Syntax

Answer

2> ‘SQL SERVER’

 

 

Q 8 >ย 

DECLARE @stringtxt as varchar(20)
SET @stringtxt=‘Microsoft SQL SERVER’

SELECT SUBSTRING( @stringtxt , null , null)ย  as output

1> ‘SQL SERVER SQL’

2> ‘SQL SERVER’

3> null

4> ‘Microsoft SQL SERVER’

Answer

3> null

 

 

Q 9 >ย 

DECLARE @stringtxt as varchar(20)
SET @stringtxt=‘Microsoft SQL SERVER’

SELECT SUBSTRING( @stringtxt , 0 ,0) as output

1> ‘Microsoft’

2> ‘SQL’

3> BLANK

4> ‘SQL SERVER’

Answer

2> BLANK

 

 

Q 10>ย 

DECLARE @stringtxt as varchar(20)
SET @stringtxt=‘Microsoft SQL SERVER’

SELECT SUBSTRING( @stringtxt , null , null)ย  as output

1> ‘SQL SERVER SQL’

2> ‘SQL SERVER’

3> null

4> ‘Microsoft SQL SERVER’

Answer

3> null

 

 

Recommended Posts..

SQL Substring()

SQL Interview Q & A Quiz on Select Statement

SQL Interview Q & A Quiz on Create statement

 2,781 total views,  8 views today

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.