declare upcur cursor for
select (datediff(day,@st_date,@ed_date)+1)-2*datediff(ww,@st_date,@ed_date) --每月要输的天数,没考虑节假日
open upcur --打开
fetch next from upcur into @work_days
select @work_days
fetch next from upcur into @work_days
close upcur --关
deallocate upcur
select (datediff(day,@st_date,@ed_date)+1)-2*datediff(ww,@st_date,@ed_date) --每月要输的天数,没考虑节假日
open upcur --打开
fetch next from upcur into @work_days
select @work_days
fetch next from upcur into @work_days
close upcur --关
deallocate upcur
本文介绍了一段SQL脚本,该脚本使用游标来计算两个指定日期之间的天数,并考虑了每周的工作日数量。通过打开和关闭游标,脚本展示了如何迭代并获取这些工作日的数据。
4336

被折叠的 条评论
为什么被折叠?



