a blog for those who code

Sunday 29 June 2014

Check a string present in another string in Sql Server

In this post we will show you how to check a string present in another string in Sql Server. We can check a string present in another string or not using CharIndex which is a built in Sql-Server method.

Declare @string Varchar(20);
Set @string = 'Some string';

Select CHARINDEX('string', @string)

The result will be 6.

If the string is not present in another string it will return 0.

Please like and share the blog if you find it helpful and interesting.

No comments:

Post a Comment