mg4377娱乐娱城官网_mg4377娱乐手机版_www.mg4377.com

当前位置: mg4377娱乐娱城官网 > mg > 正文

mg:批量数码循环插入,批量布署数据

时间:2019-09-11 08:47来源:mg
Create proc setup_list_add@creatime Datetime--创建时间,@objjc Varchar(20)--排期项目,@Doctor Varchar(20)--接诊医生,@beginDate Datetime--排班开始,@endtDate Datetime--排班结束,@objuser Varchar(20)--排班人asbeginbegin tra
Create proc setup_list_add
@creatime  Datetime--创建时间
,@objjc Varchar(20)--排期项目
,@Doctor Varchar(20)--接诊医生
,@beginDate Datetime--排班开始
,@endtDate Datetime--排班结束
,@objuser Varchar(20)--排班人
as
begin
begin transaction T1
Declare @n Datetime
set @n=@beginDate
while @n<=@endtDate
begin

 insert into Scheduling_setup(creatime,objjc,Doctor,begintime,endtime,objuser) 
 select @creatime,@objjc,@Doctor,CONVERT(char(16), @n begintime,120),endtime,@objuser from times_setup where objjc=@objjc
set @n=dateadd(dd,1,@n)
end

IF @@ERROR <> 0 GOTO FINALROLL
 select '添加成功!' msg,1 code
COMMIT TRAN T1
RETURN

FINALROLL:
    select '添加失败'  msg,2 code
ROLLBACK TRAN T1
end
Go

再也循环插入

mg 1mg 2Code
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
mg:批量数码循环插入,批量布署数据。using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

 

DELIMITER ;; 
CREATE PROCEDURE test_insert()

BEGIN 
DECLARE a INT DEFAULT 1; 
DECLARE b TINYINT DEFAULT 1; 
WHILE (a <= 100) DO 
-- repeat 


SET a = a   1; 
-- select a; 
WHILE (b <=20) DO 
insert into school_sp_mj(school_id,mojor_id,status) values(a,b,1); 
SET b = b   1; 
-- select b; 
END WHILE; 

SET b = 1; 
-- select a; 
-- until a >= i_PlayerCount 
-- end repeat; 
END WHILE; 
commit; 
END;; 
CALL test_insert();

public partial class 批量插入数据 : System.Web.UI.Page
{
    public static string sqlcon = "server=(local);user id=sa;password=;database=OfficeAutoDB";
    protected void Page_Load(object sender, EventArgs e)
    {

单循环插入

    }

DELIMITER ;; 
CREATE PROCEDURE test_insert() 
BEGIN 
DECLARE y TINYINT DEFAULT 1;
WHILE y<20
DO
insert into school_sp_mj(school_id,mojor_id,status) values(1,y,1); 
SET y=y 1; 
END WHILE ; 
commit; 
END;; 
CALL test_insert();

    protected void Button1_Click(object sender, EventArgs e)
    {
        int i = 0;
        if (List1.Items.Count > 0)
        {
            while (i < List1.Items.Count)
            {

编辑:mg 本文来源:mg:批量数码循环插入,批量布署数据

关键词: MySQL .NET技术