How To Make SQL Server Check if String Contains Specific Word / String with CHARINDEX Function in C# Asp.Net
This function is used to search for specific word or substring in overall string and returns its starting position of match. In case if no word found then it will return 0 (zero).
CHARINDEX Function
CHARINDEX ( StringToFind ,OverAllStringToSearch [ , start_location ] ) |
Example 1:
DECLARE @str VARCHAR(250) SET @str='Welcome to fantasyaspnet.blogspot.in' SELECT CHARINDEX('fantasyaspnet.blogspot.in',@str) |
Output:
--------------------------------------- 12 (1 row(s) affected) |
No comments:
Post a Comment