本文介绍了填充日期时间列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!
问题描述
我想在存储过程中动态填充日期时间列.下面是我目前使用的查询,但会降低查询性能.
I want to populate a datetime column on the fly within a stored procedure. below is the query that I currently have that does same but slows down query performance.
编写此查询以获得更好性能的最佳方法是什么?
Which is the best way to write this query for better performance?
推荐答案
改变这个:
为此:
这是获取范围内所有日期的递归公用表表达式
.然后你做一个 cross join
并插入.请注意,插入时设置顺序是没有意义的.
Here is recursive common table expression
to get all dates in range. Then you do a cross join
and insert. Notice that there is no sense to order set while inserting.
这篇关于填充日期时间列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!
本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!