ranku_mogudu Posted January 19, 2017 Report Posted January 19, 2017 I need a solution to find all positions of a substring in a string that has multiple occurrences. ed., their is a soc sec no xxx-xx-xxxx lo '-' is in position 4 and 7. I want to get a query that determines both the positions. Quote
ranku_mogudu Posted January 19, 2017 Author Report Posted January 19, 2017 @loveindia baa basic sql logic nuvvu ivvagaligina nenu teradata eq ki marchukunta Quote
rakeshchinna Posted January 19, 2017 Report Posted January 19, 2017 19 minutes ago, ranku_mogudu said: I need a solution to find all positions of a substring in a string that has multiple occurrences. ed., their is a soc sec no xxx-xx-xxxx lo '-' is in position 4 and 7. I want to get a query that determines both the positions. bro try this its complicated for you i guess but its microsoft sql (google lo dorikindi) hope it helps 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...' Declare @a table (pos int) Declare @pos int Declare @oldpos int Select @oldpos=0 select @pos=patindex('%ali%',@name) while @pos > 0 and @oldpos<>@pos begin insert into @a Values (@pos) Select @oldpos=@pos select @pos=patindex('%ali%',Substring(@name,@pos + 1,len(@name))) + @pos end Select * from @a Quote
BongaralaLingaraju Posted January 19, 2017 Report Posted January 19, 2017 select instr('123-45-6789', '-' , 1, LEVEL) from DUAL Connect by LEVEL <= REGEXP_COUNT ( '123-45-6789' , '-' ) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.