Neil Toulouse
Programmer
Hi
I am trying to clean up some code, and I came across this:
...which looks a bit of a mess to me!
Basically what it is trying to do is remove numbers from the field/vairable to find a match. For example:
fat.slug23
fat.slug3456
...the code will 'remove' the numbers so it just matches against 'fat.slug'.
Is there a better (more efficient?) way of achieving the same thing?
TIA
Neil
I like work. It fascinates me. I can sit and look at it for hours...
I am trying to clean up some code, and I came across this:
Code:
SET @lnMax = ( SELECT TOP 1 [Sequence]+1 FROM Uname WHERE
LTRIM(RTRIM(LOWER(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE([UserName],'1',''),
'2',''),'3',''),'4',''),'5',''),'6',''),'7',''),'8',''),'9',''),'0','')))) =
LTRIM(RTRIM(LOWER(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(@lcUserName,'1',''),'2',''),
'3',''),'4',''),'5',''),'6',''),'7',''),'8',''),'9',''),'0','')))) ORDER BY Sequence DESC )
...which looks a bit of a mess to me!
Basically what it is trying to do is remove numbers from the field/vairable to find a match. For example:
fat.slug23
fat.slug3456
...the code will 'remove' the numbers so it just matches against 'fat.slug'.
Is there a better (more efficient?) way of achieving the same thing?
TIA
Neil
I like work. It fascinates me. I can sit and look at it for hours...