sqlserver存储过程插入一年的日期到一个表 博客分类: sqlserver 存储过程 sqlserver存储过程日期
程序员文章站
2024-03-16 18:11:22
...
drop procedure pro_create_days; CREATE PROCEDURE [dbo].[pro_create_days] @v_date varchar(4) as DECLARE @rq varchar(10) select @rq = @v_date+'-01-01'; while (@rq <= @v_date+'-12-31' ) begin if not exists(select 1 from jx_days where rq = @rq) begin insert into jx_days(rq) values(@rq); end select @rq = convert(varchar(10),dateadd(day,1,convert(datetime,@rq,120)),120); end