Often when coding I’ll search for a snippet of code to avoid reinventing the wheel. Code re-use is good, right?
From now on, whenever a search like that ends up sending me over to experts-exchange.com (which is a signup, members only site that shows the question text for all to see but masks the answers to entice people to sign up) I’m going to make an effort to write up a free version of the answer here.
I really dislike that site, because all hits from there are a complete waste of time for a non member. I’d love to hear from anyone who has a membership as to what sort of quality answers are hiding behind those obfuscation layers. It’d be nice if google would let you create a list of ‘never show results from these sites’ to my account settings – it’d be a lot quicker than having to append ‘-site:experts-exchange.com’ all the time. Maybe their new Custom Search Engine offering could go some way to filling that void, however I digress.
Anyway, here’s a quick piece of SQL allowing you to update a table to remove trailing commas. It’s easily adaptable to replace other characters, or to remove leading characters as well.
update Location set Suburb = left(Suburb,len(Suburb)-1) where Right(Suburb,1) = ','
Not a complex piece of SQL by any means, but if it saves someone 5 minutes then job done.