数据库教程:用SQL批量插入数据的代码

复制代码 代码如下: declare @mycounter int set @mycounter = 0 /*设置变量*/ while (@mycounter < 2

复制代码 代码如下:
declare @mycounter int
set @mycounter = 0 /*设置变量*/
while (@mycounter < 2) /*设置循环次数*/
begin
waitfor delay ‘000:00:10’ /*延迟时间10秒*/
insert into time_by_day
(time_id, the_date, the_year, month_of_year, quarter, day_of_month)
select top 1 time_id + 1 as time_id, the_date + 1 as the_date, year(the_date + 1)
as the_year, month(the_date + 1) as month_of_year, { fn quarter(the_date + 1)
} as quarter, day(the_date + 1) as day_of_month
from time_by_day
order by time_id desc

set @mycounter = @mycounter + 1
end

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/dtteaching/618547.html

(0)
上一篇 2021年5月21日
下一篇 2021年5月21日

精彩推荐