How can I update many SQL rows in one table?

I have a table and one of the columns contains web addresses such as: "http: // ..." or "https: // ...".

The problem is that there are some invalid entries like "shttp: // ..." or "#http // ..." (the first character is not valid) and I want to fix them all.

I am using the following SQL statement:

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

      

and I am successfully getting problematic lines.

But how am I going to change / fix all of them using the instruction UPDATE

? If you have another solution, please share it!

+2


source to share


2 answers


Just change SELECT to UPDATE (with some syntax changes of course) with the "fix" statement



UPDATE
   MyTable
SET
    WebAddress = SUBSTRING(WebAddress, 2, 8000)
WHERE
    WebAddress LIKE '_http%'

      

+3


source


You can use the Sub string property as you can trim odd letters. Just like "_word start" is appropriate for your question



0


source







All Articles