If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > PatIndex vs Like

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-04-10, 06:38
Enigma Enigma is offline
The SQL Apostle
 
Join Date: Jul 2003
Location: The Dark Planet
Posts: 1,387
PatIndex vs Like

My tests show both of them perform exactly the same... any conditions where either one may have an advantage ???
__________________
Get yourself a copy of the The Holy Book

order has no physical Brett in The meaning of a Kaiser . -database data
Reply With Quote
  #2 (permalink)  
Old 02-04-10, 06:49
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
If you are looking for PATINDEX = 1 and the predicate is on an indexed column.

Like can seek. Patindex will scan.

Google "sargable"
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #3 (permalink)  
Old 02-04-10, 07:09
corncrowe corncrowe is offline
Registered User
 
Join Date: Aug 2004
Location: Dublin, Ireland
Posts: 152
You can also use PATINDEX in a substring function but LIKE doesn't work so well.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On