sqlserver存储过程插入一年的日期到一个表

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	

你可能感兴趣的:(存储过程,sqlserver,日期)