Skip to content
Advertisement

How to delete row contain specific string on it in SQL Server

There are lots of rows that contain ’08:28:00.000′ in my table,like this one:

open    high    low close   volume  datetime
324.55  324.55  324.48  324.53  20945   2020-07-22 08:28:00.000
334.54  325.57  324.94  322.54  23947   2020-07-23 08:28:00.000

I want to delete all the rows that ‘datetime’ contains ’08:28:00.000′.Instead of deleting this kind of rows one by one,is any command can delete all the rows than datetime contain ’08:28:00.000′?

Advertisement

Answer

Try using a range delete query here, after extracting time from the datetime column:

DELETE
FROM yourTable
WHERE CONVERT(time, datetime) = '08:28:00.000';
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement