SELECT DATEADD(HOUR,1,'2015-01-01 00:00:00') h INTO vinson_h

DELETE vinson_h

DECLARE @num INT=0
DECLARE @h int
SELECT @h=DATEDIFF(HOUR,'2015-01-01 00:00:00',GETDATE())
WHILE(@num<=@h)
BEGIN
    INSERT INTO vinson_h(h) values (DATEADD(HOUR,@num,'2015-01-01 00:00:00'))
    SET @num=@num+1
END

SELECT * FROM vinson_h
ORDER BY h DESC 

posted on 2018-11-02 09:56  vinsonLu  阅读(1525)  评论(0编辑  收藏  举报