CHARINDEX (Transact-SQL)

·

·

Syntax:

CHARINDEX ( expressionToFind ,expressionToSearch [ , start_location ] )

A. Returning the starting position of an expression

The following example returns the position at which the sequence of characters bicycle starts in the DocumentSummary column of the Document table.

USE

AdventureWorks2012;

GO

DECLARE @document varchar(64);

SELECT @document =‘Reflectors are vital safety’+ ‘ components of your bicycle.’;

SELECT CHARINDEX(‘bicycle’, @document);

GO

Here is the result set.

———–

48

 

Source: http://msdn.microsoft.com/en-us/library/ms186323.aspx



Leave a Reply

Your email address will not be published. Required fields are marked *