SQL Server 2005:charindex starting from the end -


I have some string 'file.name', I want to capture some 'file'.

To do this, I need to search for the last event. 'In a string.

My solution is:

  Declare @someStr varchar (20) Announced @reversedStr varchar (20) Announce @ index int set @someStr = '001.002 003' set @reversedStr = reverse (@someStr) set @ index = lan (@sOSATR) - select the charandx ('.', @ Reversed STR) (@ some ST, @ index)  

Well, is not it too complicated? I'm just ready to use some of the files.

Does anybody have a good idea?

What do you need to do with it ?? Do you need to catch the letters after the last chance of a given delimiter?

If this is the case: Reverse the strings and search using the usual CHARINDEX:

  Announce @test negotiation (100) set @test = 'some.file Name 'declare @ ruchars varchar (100) set @reversed = reverse (@test) select reverse (SUBSTRING (@ in return, CHARINDEX ('. ', @reversed) +1, 100))  < / Pre> 

You will receive "some.file" back - the previous ".in the original file name.

You do not have any" LASTCHARINDEX "or something that is not directly in SQL Server. What are you doing in a great net. Extension A The extensions library and it can be applied as an assembly in SQL Server - T-SQL string is not strong enough to manipulate, while NAT is actually.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -