Remove trailing characters (and a small rant)

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.

Tags:

 Print | Posted on Wednesday, July 09, 2008 2:50 PM | Filed Under [ Miscellaneous SQL ]


Feedback

Gravatar

# re: Remove trailing characters (and a small rant)

I've been wanting the same feature for exactly the same site (and a few others).

[)amien

7/9/2008 3:26 PM | Damien Guard

Gravatar

# re: Remove trailing characters (and a small rant)

Hi Damien,

Wow that's really weird - I was just reading your blog about 10 minutes ago..

I just started having a look at the google custom search product. It looks like it has potential, however it works on a whitelist rather than a blacklist. Need a bit more time to explore it fully.

If it's not there I might end up writing something. You'd think it would be a fairly common request though..

Ross

7/9/2008 4:42 PM | Ross Hawkins

Gravatar

# re: Remove trailing characters (and a small rant)

Interestingly I have a friend who belongs to Experts Exchange as a PAID member (about $10/Month from memory). Now he's a paid member because it means his queries get answered very quickly - on the day we met for lunch he'd asked for a regex before hand and it was done when he got back to the office. Nice.

As an aside (I don't know if this is because I have js disabled by default) but I can always see the answers on Experts Exchange if I scroll down far enough (past all the ads and junk). Is this just me?


Andy.

7/14/2008 1:39 PM | Andrew Baird

Gravatar

# re: Remove trailing characters (and a small rant)

Hey Andy,

Yeah Sam pointed that out to me too - he's been pulling the results from google's cache to get the same effect. It's interesting to know that your friend rates Experts Exchange though - maybe I was a bit hasty to jump to conclusions about their content!

7/14/2008 4:54 PM | Ross Hawkins

Gravatar

# re: Remove trailing characters (and a small rant)

Hi Ross

Thanks for the SQL code - I'm sure it will fix my problem - I have been left with a whole pile of trailing spaces on FirstName from someone else's conversion = makes Dear <FirstName>, look a bit silly on a merger.

I support you re experts-exchange.com - I'm sick of their half answers coming up in searches - maybe it's downunder thunking

Pete ( in brisbane)

7/19/2008 6:48 PM | Pete

Gravatar

# re: Remove trailing characters (and a small rant)

In experts-exchange, scroll down down and after the non-available answers you will see the proposed and accepted solutions without having to log into the site :p

8/15/2008 4:27 AM | Carlos

Post Comment

Title  
Name  
Email
Website / Url
 

Your comment

   
Please add 8 and 1 and type the answer here:

About me

My name is Ross Hawkins and I'm a Developer, Consultant and Writer based in Auckland, New Zealand. My current work revolves around ASP.NET, C#, Ajax, SQL Server, and a mix of other Microsoft development technologies. Previously I spent about 11 years working with Lotus Notes/Domino.


Subscribe

Subscribe to this feed


Search


Popular Content

Troubleshooting WebResource.axd

The .NET 2.0 framework changed the way clientside JavaScript is delivered to the browser. Previously, ASP.NET 1.1 used the aspnet_client directory whereas now 2.0 uses WebResource.axd.

Published on October 8, 2006

Microsoft AJAX Extensions: Sys.Debug is null or not an object

One of the breaking changes which was made with the 1.0 release of the Microsoft Ajax Extensions was the renaming of the 'Debug' class to 'Sys.Debug' for reasons of compatiability with other frameworks. Breaking changes like this can often be a source of frustration..

Published on May 22, 2007

Simple ASP.NET Character Counter

A textbox character counter is a pretty simple piece of functionality, and there's a lot of different ways to apply one to your application. The following method is nice and simple, and can be done using only clientside JavaScript if required, or combined with server side code in order to create a more dynamic effect

Published on December 4, 2006

Adding Tooltips to Gridview Headers

As the title says, this is a very simple but dynamic way of achieving tooltip text on a header column. It's not overly flash, but it's lightweight and quick to implement.

Published on April 15, 2007

SQL Server Web Report Viewer Issues on Windows 2008 Server/IIS7

A fix for another AXD related issue, this time with the SQL Server Web Report Viewer Control which was being served up via IIS7 on a Windows 2008 server.

Published on June 2, 2007
Updated on April 10, 2008


Archives

January, 2009 (2)
December, 2008 (6)
November, 2008 (7)
October, 2008 (9)
September, 2008 (12)
August, 2008 (9)
July, 2008 (6)
June, 2008 (24)
May, 2008 (13)
April, 2008 (16)
March, 2008 (8)
February, 2008 (10)
January, 2008 (1)
December, 2007 (14)
November, 2007 (11)
October, 2007 (11)
September, 2007 (13)
August, 2007 (11)
July, 2007 (5)
June, 2007 (15)
May, 2007 (11)
April, 2007 (9)
March, 2007 (9)
February, 2007 (10)
January, 2007 (8)
December, 2006 (18)
November, 2006 (11)
October, 2006 (14)
September, 2006 (9)
August, 2006 (10)
July, 2006 (4)
June, 2006 (4)
May, 2006 (6)
April, 2006 (3)
February, 2006 (6)
January, 2006 (10)
September, 2005 (2)
August, 2005 (4)

Post Categories

ASP.NET
AJAX
Amusing
NZ
NZ Trains
Notes/Domino
Visual Studio
Web Development
Miscellaneous
Me
Rugby
C#
SQL


Twitter