从特定月份的表格中删除数据

时间:2023-01-20 19:38:40

In My Table, I Have a Column Which Stores the Date. I am Passing Month Number as an argument to a stored Procedure.

在我的表中,我有一个存储日期的列。我将一个月号作为一个存储过程的参数。

I would like to delete all entries of that month from table.

我想从表中删除那个月的所有条目。

Is it Possible....??

有可能.... ? ?

5 个解决方案

#1


5  

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 the year part of your date so if it is may-2014 or may-2015, all will be deleted.

注意:用输入参数替换5。这不会考虑你的日期的年份部分,所以如果是2014年5月或2015年5月,所有的都将被删除。

#2


2  

I am not familiar with SQL server versions, but youre tagged as 2005.

我不熟悉SQL server版本,但是您被标记为2005。

If there is issues with month() then you can also use;

如果一个月()有问题,你也可以使用;

delete from your_table where datepart(month, table_datefield) = @procedure_argument_month

But as in other answer, this will delete all fields which month is as you provided, as you described, not minding the year.

但与其他答案一样,这将删除您所提供的所有字段,如您所描述的,而不考虑年份。

#3


0  

delete from TABLE_NAME
where DATEPART(mm,ColumnName) = @MONTH_PARAMETER

#4


0  

It will work for you :

它将对你有用:

delete from [tablename] 
where DATEPART(month,[datecolumn]) = @inputDigit

#5


0  

Here in given Query pass your month in Digit of which month you want to delete the data.

在这里的给定查询中,以您想要删除数据的月份的数字传递您的月份。

Delete from tbl_xyz where DATEPART(mm, clm_CreatedTime) = @Month

#1


5  

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 the year part of your date so if it is may-2014 or may-2015, all will be deleted.

注意:用输入参数替换5。这不会考虑你的日期的年份部分,所以如果是2014年5月或2015年5月,所有的都将被删除。

#2


2  

I am not familiar with SQL server versions, but youre tagged as 2005.

我不熟悉SQL server版本,但是您被标记为2005。

If there is issues with month() then you can also use;

如果一个月()有问题,你也可以使用;

delete from your_table where datepart(month, table_datefield) = @procedure_argument_month

But as in other answer, this will delete all fields which month is as you provided, as you described, not minding the year.

但与其他答案一样,这将删除您所提供的所有字段,如您所描述的,而不考虑年份。

#3


0  

delete from TABLE_NAME
where DATEPART(mm,ColumnName) = @MONTH_PARAMETER

#4


0  

It will work for you :

它将对你有用:

delete from [tablename] 
where DATEPART(month,[datecolumn]) = @inputDigit

#5


0  

Here in given Query pass your month in Digit of which month you want to delete the data.

在这里的给定查询中,以您想要删除数据的月份的数字传递您的月份。

Delete from tbl_xyz where DATEPART(mm, clm_CreatedTime) = @Month