如何用工作日更新表格? [英] How to update table with week days?

查看:97
本文介绍了如何用工作日更新表格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





DECLARE @Product TABLE (Date_From Datetime, Date_To Datetime, Product_ID INT, WeekDay INT)





DECLARE @Beg varchar(50), @End varchar(50)
SET @one = 'Monday'
SET @two = 'Tuesday'
SET @three = 'Friday'



我想使用sql查询更新我的@product表,如下所示

日期范围是



I want to update my @product table like below using sql query

date range is

20/03/2011 to 31/03/2011



我需要像下面这样的输出



Out put i need like below

2011-03-20  2011-03-20  101  
2011-03-21  2011-03-22  101 Mon,Tue
2011-03-23  2011-03-24  101
2011-03-25  2011-03-25  101 Fri
2011-03-26  2011-03-27  101 
2011-03-28  2011-03-29  101 Mon,Tue
2011-03-30  2011-03-31  101

推荐答案

似乎您已根据某些逻辑拆分了日期范围.您似乎在输出中通常具有不同的日期,但有时(20日,25日)您具有相同的日期...

但是,我可能建议您看一下这篇文章,因为它涉及到您正在处理的问题:使用表SQL Server中的有价值的函数 [ ^ ]
Seems that you splitted the date range based on some logic. You mostly seem to have different dates in the output but sometimes (20th, 25th) you have the same date...

However may I suggest that you have a look at this article since it touches the issue you''re working with: Using Table-Valued Functions in SQL Server[^]


这篇关于如何用工作日更新表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆