What will happen,when we execute below query?

Select Substring('Vishal Kumar','Neeraj',10) as Portion;

 Posted by vishalneeraj-24503 on 1/24/2014 | Category: Sql Server Interview questions | Views: 1895 | Points: 40

It will give us below error:

Msg 8116, Level 16, State 1, Line 1
Argument data type varchar is invalid for argument 2 of substring function.

Meaning that,we can not pass varchar value in 2nd and 3rd parameter because substring function takes integer value in 2nd and 3rd parameter that is start_position and string_length.
so always give numeric value in start_position and string_length parameter.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response