SQL Server : deleting rows by month name

How do I delete by month name instead of date number?

I would like to use ‘April’ instead of ’04’

  • SELECT TOP N WITH TIES @scalar_value = count(*)
  • Centralised database connection string provider
  • Execute SQL Server 7 DTS on SQL Server 2008
  • Sql group by only consecutive rows
  • Converting SQL Geography Lat/Long to VARCHAR without loss of precision
  • Create package for large table in SQL Server
  • This is as far as i have gotten, but it still does not work.

    DELETE * 
    FROM myTable 
    WHERE CONVERT(DATE, myColumn) LIKE 'April'
    

    2 Solutions collect form web for “SQL Server : deleting rows by month name”

    DELETE
    FROM
        MyTable
    WHERE
        DATENAME(MONTH,myColumn) LIKE 'April'
    

    since SQL-SERVER 2008 you can use DATENAME() function to extract it from a date. I personally would still prefer the integers but since you asked….

    https://msdn.microsoft.com/en-us/library/ms174395.aspx

    You can use function DATENAME, see documentation here: https://msdn.microsoft.com/en-us/library/ms174395.aspx

    In your case, it would be:

    DELETE FROM MyTable WHERE DATENAME(MONTH,myColumn) LIKE 'April'
    
    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.