July 8, 2003 at 4:03 pm
We have a stored procedure that eliminates extraneous spaces so that matches can be more quickly made. One of the things that came to mind is to use REPLACE to get rid of the unwanted spaces, so:
set @TestName = replace(@TestName, ' ', '')
but that still leaves the original spaces. I saw the BOL but wasn't really clear on what I saw. The current procedure cycles through all characters and checks if they're a space and does a LEFT and RIGHT of the space to remove it. Is there a way to use REPLACE, or something like it to keep the code easy to read?
TIA
Andre
July 8, 2003 at 11:07 pm
if there are leading and trailing spaces. you can use ltrim and rtrim.
i would suggest you to provide a example and expected result. it will be easy for the members to assist you.
July 9, 2003 at 1:50 pm
Are you running SQL 7.0? The REPLACE statement works for me the way you tested it originally. It seems like there was a setting to avoid *empty* strings.
As a test you could try
set @testname = replace( @testname, ' ', '~' )
Which should change all the spaces to tildes. If it does, look for the setting to allow empty strings.
Guarddata-
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply