日期:2014-05-17 浏览次数:20471 次
declare @b datetime,@e datetime
set @b='2009-1-1'
set @e=dateadd(y,1,@b)
while @b<@e
begin
insert tby values (@b,'....')
set @b=@b+1
end
--日期差还要加1
create proc pro_a3
@state datetime,
@end datetime
as
declare @day int
set @day = datediff(day,@state,@end)
declare @i int
set @i=1
while @i<=@day+1
begin
--你的sql语句
--insert into a (smalldatetime) values('2012-5-5')
set @i=@i+1
end
go
exec pro_a3 '2013-05-01','2013-05-22'