Reputation: 11
I have a table in my database. It contains 35 columns and 150 rows. Some of its values are 0. How can I replace these 0 with the character '-' ?
Upvotes: 0
Views: 48
Reputation: 6896
In SQL Server:
SELECT REPLACE(Column1,'0','-'),REPLACE(Column2,'0','-'), REPLACE(Column3,'0','-')etc..
FROM YOUR_TABLE_NAME;
Upvotes: 0
Reputation: 12378
Just use UPDATE
to do this:
UPDATE yourtable
SET col1 = CASE WHEN col1 = '0' THEN '-' ELSE col1 END,
col2 = CASE WHEN col2 = '0' THEN '-' ELSE col2 END,
col3 = ....
Upvotes: 1