Reputation: 21
I have a column in SQL Server table which has a mix of a string 'Wait' or numbers. How can I change this to a 0
(zero). There are 250,000 records with about 10,000 with the string.
Upvotes: 0
Views: 1089
Reputation: 396
this one will replace string starts with 'WAIT'\
UPDATE TABLE_NAME SET COLUMNNAME = 0
WHERE COLUMNNAME LIKE 'WAIT%'
or this one will check and replace string contains 'WAIT' anywhere
UPDATE TABLE_NAME SET COLUMNNAME = 0
WHERE COLUMNNAME LIKE '%WAIT%'
before update please check the result set is correct or not by using below select query
select COLUMNNAME from TABLE_NAME WHERE COLUMNNAME LIKE 'WAIT%'
select COLUMNNAME from TABLE_NAME WHERE COLUMNNAME LIKE '%WAIT%'
Upvotes: 0
Reputation: 13509
Do you need below -
UPDATE YOUR_TABLE
SET COLUMN = 0
WHERE UPPER(COLUMN) LIKE '%WAIT%'
Upvotes: 1