在sql中如何统计每月当中的最后一天是几号
解决方案 »
- 事件查看器
- SQL Server2000分离的mdf文件附加到SQL Server 2005中报错
- sql中公式的使用
- 为什么我执行backup log *** with no_log时报错呢?
- 请问高手:怎么在触发器或者存储过程中,调用一个WINDOWS应用程序?急啊
- 如何设置远程连接sql 2005 express
- VS2008无法添加数据连接
- 未解决!SQL2000与SQL2005,SQL2008临时表的效率问题!
- 请问如向判断SQL的不同版本?
- 挑战:如何用存储过程实现任意查询
- Microsoft SQL Server\90\Setup Bootstrap\LOG\Files 下面的日志文件可不可以删除?
- 进来看看,有几种方法
declare @month int
set @month = 1
while @month <=12
begin
select @month as month,day = day(dateadd(day,-1,dateadd(month,1,'1900-' + rtrim(@month) + '-1')))
set @month = @month + 1
end
set nocount on
declare @month int,@year int
set @year = 2000
while @year < 2010
begin
set @month = 1
while @month <=12
begin
select
[datetime] = dateadd(day,-1,dateadd(month,1,rtrim(@year) + '-' + rtrim(@month) + '-1')),
[LastDay] = day(dateadd(day,-1,dateadd(month,1,rtrim(@year) + '-' + rtrim(@month) + '-1')))
set @month = @month + 1 /*指定月*/
end
set @year = @year + 1 /*指定年*/
end
得到本月的最后一天,getdate()可换成其他的日期