Use Of PatIndex in SQL Server

Posted by Amatya under Sql Server on 8/6/2015 | Points: 10 | Views : 893 | Status : [Member] | Replies : 4
What is PatIndex, and How it can be helpful in SQL, where we can use it?

Feel free to share informations 9731764134
mail Id ' adityagupta200@gmail.com
Thanks



Responses

Posted by: Sriharim on: 8/9/2015 [Member] Starter | Points: 25

Up
0
Down
The SQL Server PATINDEX functions returns the location of a pattern in a string. The search is not case-sensitive.

Syntax:
PATINDEX( '%pattern%', string )

You can get more info in
http://www.techonthenet.com/sql_server/functions/patindex.php

https://msdn.microsoft.com/en-IN/library/ms188395.aspx

---
Srihari

Amatya, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 8/10/2015 [Member] [MVP] Platinum | Points: 25

Up
0
Down
PATINDEX functions returns the location of a pattern in a string. The search is not case-sensitive.

syntax:
PATINDEX( '%pattern% ', string )

The pattern that you want to find. pattern must be surrounded by % characters. Other wildcard characters can be used in pattern, such as:

% -- Allows you to match any string of any length (including zero length)
_ -- Allows you to match on a single character
[ ] -- Allows you to match on any character in the [ ] brackets (for example, [aeiou] would match on a, e, i, o, or u characters)
[^] -- Allows you to match on any character not in the [^] brackets (for example, [^aeiou] would match on any character that is not a, e, i, o, or u characters)

refer this link for some example
http://sqlandme.com/2011/07/05/sql-functions-patindex/

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Amatya, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajesh123 on: 8/10/2015 [Member] Starter | Points: 25

Up
0
Down
PATINDEX is used to get starting position of the first occurrence of a pattern in a specified expression.
Syntax of PATINDEX Function :
PATINDEX ( '%pattern%' ,expression )

Example:
Use of PATINDEX function in select clause

SELECT PATINDEX('%-E%','Syntax-Example') ;
Output
7
Above example returns position of starting index for characters '-E' in specified string.


Refer below link some examples
http://www.dailyfreecode.com/code/patindex-function-291.aspx

rajesh.plsql123@gmail.com

Amatya, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Amatya on: 8/11/2015 [Member] Silver | Points: 25

Up
0
Down
Thanks Bandi.. :)

Feel free to share informations 9731764134
mail Id ' adityagupta200@gmail.com
Thanks

Amatya, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response