views:

54

answers:

2

Hi folks.

I have a table and one of the columns holds web addresses like: 'http://...' or 'https://...'.

The problem is that there are some invalid entries, like 'shttp://...' or '#http//...' (the first character is invalid) and I want to correct all of them.

I use the following SQL statement:

'SELECT [...] FROM MyTable WHERE WebAddress LIKE '_http%'

and I successfuly get the problematic rows.

But how am I going to change/correct all of them using an UPDATE statement? If you have some other solution please share it!

+4  A: 

Simply change the SELECT to an UPDATE (of course, with some syntax changes) with a "fix" expression

UPDATE
   MyTable
SET
    WebAddress = SUBSTRING(WebAddress, 2, 8000)
WHERE
    WebAddress LIKE '_http%'
gbn
shouldn't we use LEN(WebAddress)-1 instead of 8000?
Veer
@Veer: only if you want to use 2 functions rather than one... :-)
gbn
@gbn got it :)...
Veer
A: 

You Can use Sub string property as you can trim odd letters .Also like '_word start' suitable for your question

KareemSaad