What is the difference between SUBSTR and CHARINDEX in the SQL Server?
The SUBSTR function is used to return specific portion of string in a given string. But, CHARINDEX function gives character position in a given specified string.
SUBSTRING('Smiley',1,3)
Gives result as Smi
CHARINDEX('i', 'Smiley',1)
Gives 3 as result as I appears in 3rd position of the string