Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

CHARINDEX with start_location

Posted on 2010-09-17
4
412 Views
Last Modified: 2012-05-10
do not understand why the result is the same if the difference is in the parameter start_location
charINDEX.jpg
0
Comment
Question by:enrique_aeo
  • 2
  • 2
4 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 33705186
Because all the start position parameter does is tell SQL Server, "ignore any instances of the substring that start before ".
0
 

Author Comment

by:enrique_aeo
ID: 33705280
i do not understand very well
i confuse because msdn tell
Is an integer or bigint expression at which the search starts. If start_location is not specified, is a negative number, or is 0, the search starts at the beginning of expression2.
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 250 total points
ID: 33705307
Which is the same thing that I said, really :)By passing a 5 for the 'start at' parameter, you are not shortening the string.  You are simply stating where the search should start.  The starting character position for the found substring is still measured relative to the beginning.For example:DECLARE @str varchar(100)SET @str = 'This foo is a test foo'SELECT CHARINDEX('foo', @str)       /* returns 6 */SELECT CHARINDEX('foo', @str, 7)   /* returns 20 */That second 'foo' starts at position 20; by passing 7 for the 'start at' parameter, we ignore the 'foo' that started at position 6.
0
 

Author Closing Comment

by:enrique_aeo
ID: 33705344
your example is much better. Thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question