Reputation: 1882
I have a lot of rows with values with percentage sign that I would like to remove from a column.
Is there a good SQL query to achieve this?
Upvotes: 2
Views: 5253
Reputation: 1
If your DBMS does NOT have a "replace" function, you will have to use character substitution using several string functions.
Here is an example in Sybase and SQL Server.
UPDATE YourTable
SET YourColumn = stuff(YourColumn, patindex(YourColumn, '%'), 1, NULL)
This code will find the pattern of '%' in YourColumn, then use that position number to replace the character with NULL.
Upvotes: 0
Reputation: 204924
update your_table set your_column = replace(your_column, '%', '')
Upvotes: 1
Reputation: 135938
Use the REPLACE function:
UPDATE YourTable
SET YourColumn = REPLACE(YourColumn, '%', '');
Upvotes: 8