SQL statement needed to remove characters

5 pts.
Tags:
SQL Server
SQL Server 2008
SQL statements
SQL tables
I have data in one of my columns in a table that I would like to remove via a SQL update statement.  In all cases, the data that I want to remove is the same 3 characters at the end of the varchar field.   How would I structure the SQL statement?

Software/Hardware used:
MS SQL Server 2008

Answer Wiki

Thanks. We'll let you know when a new response is added.

Look at the substring statement.
<pre>
UPDATE YourTable
SET Column = SUBSTRING(Column, 0, len(Column)-3)
WHERE AnotherColumne = ‘Something'</pre>

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Kccrosser
    If you are trying to remove a specific pattern of 3 characters at the end of a field, you could use: UPDATE YourTable SET Column = LEFT(Column, LEN(Column)-3) WHERE Column like '%xxx' Change "xxx" to the pattern to be removed.
    3,830 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following