Skip to main content
Question Protected by CommunityBot
edited tags
Link
Paul White
  • 90.3k
  • 30
  • 424
  • 663
Tweeted twitter.com/StackDBAs/status/724491145955385344
added 18 characters in body; edited title
Source Link
Aaron Bertrand
  • 181.5k
  • 28
  • 402
  • 619

how How to find all position with patindexpositions of a string within another string

howHow can I find all positionthe positions with patindexpatindex in tbalea table or variable?

declare @name nvarchar(max)
set @name ='ali reza dar yek shabe barani ba yek  dokhtare'
  + 'dokhtare khoshkel be disco raft va ali barayebaraye'
  + ' 1 saat anja bud va sepas... ali...'
select patindex('%ali%',@name) as pos 

up select return 1 but i want all results

This returns 1 but I want all results, e.g.:

    pos
   ========
    1
    74
    113

how find all position with patindex

how find all position with patindex in tbale or variable?

declare @name nvarchar(max)
set @name ='ali reza dar yek shabe barani ba yek  dokhtare khoshkel be disco raft va ali baraye 1 saat anja bud va sepas... ali...'
select patindex('%ali%',@name) as pos 

up select return 1 but i want all results

    pos
   =====
    1
    74
    113

How to find all positions of a string within another string

How can I find all the positions with patindex in a table or variable?

declare @name nvarchar(max)
set @name ='ali reza dar yek shabe barani ba yek  '
  + 'dokhtare khoshkel be disco raft va ali baraye'
  + ' 1 saat anja bud va sepas... ali...'
select patindex('%ali%',@name) as pos 

This returns 1 but I want all results, e.g.:

pos
===
  1
 74
113
edited title
Link
Ario
  • 1.1k
  • 4
  • 14
  • 27

how find all position with patindex in

Source Link
Ario
  • 1.1k
  • 4
  • 14
  • 27
Loading