标签:
--创建表 create table WeekDays( id int primary key identity(1,1), WeekDay nvarchar(20), Status int --判断是否启用 )
----添加一年的工作日 DECLARE @num int DECLARE @count int set @num = 1 set @count = 1 WHILE @num <=365 --时间跨度有闰年的就是366天 begin INSERT into WeekDays VALUES ( convert(nvarchar(10),dateadd(dd,@num, ‘2017-07-05‘),23),1)-- 2017-07-05 星期三 if @count=2 begin set @num = @num+3 set @count = @count+3 end else begin set @num = @num+1 set @count = @count+1 end IF @count = 8 set @count = 1 end
SQLserver 向表中添加工作日,不排除节假日,只排出星期六星期日
标签:
原文地址:http://www.cnblogs.com/123fang/p/5638008.html