Delete data from a table of a specific month
5 answers
I think this is your answer:
delete from yourtable where month(YourDatetimeColumn) = 5 -- for example 'may'
OR
delete from yourtable where datepart(mm,YourDatetimeColumn) = 5 -- for example 'may'
Note: replace 5
with your input parameter. This will not consider part of year
your date, so if it could be 2014 or May 2015, all will be deleted.
+5
source to share
I'm not familiar with the SQL server versions, but you tagged as 2005.
If there are problems with month()
, you can also use;
delete from your_table where datepart(month, table_datefield) = @procedure_argument_month
But as in the other answer, this will remove all fields that are month as you specified as you described, regardless of the year.
+2
source to share