Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trim/Delete string from Table

Status
Not open for further replies.

benjatado

Programmer
May 15, 2005
52
US
I am trying to find a way to DELETE or TRIM the word 'Track' from a column of values where the values look like:
Track 01
Track 02
Track 03... etc.

I would like to delete the word Track from this column. I am aware of the SELECT SUBSTRING(string,start_char,len) function... but I really want to permanently delete this 'Track' from all of the records in the column.

Any help would be greatly appreciated!!

-Thanks!!

 
Use the replace function.
Code:
select replace('Track 234', 'Track ' , '')

Regards,
AA
 
Hard-coded example should look like:
Code:
UPDATE myTable
SET myColumn = substring(myColumn, 7, anylargeenoughnumber)
WHERE myColumn LIKE 'Track %'

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
I did not realise you wanted a update the table.

Use this:
Code:
update Test
set name = replace(Name, 'Track' , '')

Regards,
AA
 
Thanks!
This worked like a charm!
Code:
Update TableName

Set ColumnName = replace(ColumnName, 'Value', 'New Value')

Brilliant!

I also used this to Set = LTRIM() to delete some of that annoying whitespace... works great.

Thanks!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top