create  PROCEDURE insertinto
as
begin
declare @id int;
set @id=1;
while @id<10
begin
insert into person (id,name) values(@id,'123')
set @id=@id+1
end
end

批量插入数据:
定义变量,执行循环,将int转化为varchar。例如:convert(varchar(10),@bmc)

declare @name  varchar(50);
declare @pwd varchar(10);
set @pwd='123456';
    declare @bmc int;
        set @bmc=101;
     while(cast(@bmc as int) <120)
      begin
        set @name='TV8'+convert(varchar(10),@bmc);        
        insert into dbo.T_TopView_Admin(F_Psnid,F_status,F_BroPwd,F_Edittime,F_StartTime,F_EndTime,F_UserType) values('TV8'+convert(varchar(10),@bmc),1,'123456',getdate(),20080320,20090319,1)
        set @bmc=@bmc+1
      end

批量插入数据,这个实例是用户两个数据结构类似的两张表进行数据导入

declare @fid int;
    set @fid=1;
while @fid<100
begin
    insert into T_Mail_Test_Attach(F_ID,F_ContentID,F_AttachName,F_AttachSize,F_AttachAddress,F_EditTime) select top 1 F_ID,F_MailID,F_AttachName,F_AttachSize,F_AttachAddr,F_EditTime from dbo.T_TLMail_Attach where F_ID>@fid order by F_ID asc
    set @fid=@fid+1
end

sql 批量插入的更多相关文章

  1. SQL批量插入表类 SqlBulkInsert

    ado.net已经有了sqlBulkCopy, 但是那个用xml格式,网络传输数据量太大. 自己实现了一个,传输尽量少的字节. 性能没对比过,有需要的自己拿去测试. using System.Data ...

  2. insert into select 与select into from -- sql 批量插入

    参考资料:http://www.w3school.com.cn/sql/sql_union.asp   UNION:操作符用于合并两个或多个select语句的结果集.                 ...

  3. Delphi中SQL批量插入记录

    http://www.cnblogs.com/azhqiang/p/4050331.html 在进行数据库操作时, 我们经常会遇到批量向数据库中写入记录的情况. 在这里我提供3种操作方式:   1.  ...

  4. Sql批量插入方法

    using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Sy ...

  5. 使用SQL批量插入数据到数据库 以及一些SQL函数的语法

    批量插入100条记录 set nocount on declare @i int=1; while @i<=100 begin Insert into Client(id,ClientCode, ...

  6. SQL 批量插入数据

    后面进行完善修改. /*批量插入数据*/ 这个比较完善.直接插入数据库表. INSERT INTO `goods_transverter` ( `code`,`es_id`,`barcode`, `n ...

  7. sql批量插入缓慢

    1.有一个普通的表t_asset,只有2个字段id,ip 没有索引 2.当用insert into t_asset(id,ip) values(?,?),(?,?) 1200多条记录时,发现竟然用了3 ...

  8. sql 批量插入数据到Sqlserver中 效率较高的方法

    使用SqlBulk #region 方式二 static void InsertTwo() { Console.WriteLine("使用Bulk插入的实现方式"); Stopwa ...

  9. Sql批量插入时如果遇到相同的数据怎么处理

    测试数据 -- 创建测试表1 CREATE TABLE `testtable1` ( `Id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, `UserId` I ...

随机推荐

  1. Linux下设置Tomcat开机自启动

    --未验证 第一步:在/etc/init.d下新建一个文件tomcat(需要root操作权限) vi /etc/init.d/tomcat 然后点击"i"写下如下代码,tomcat ...

  2. Java 8 Lambda表达式学习和理解

    Java 8 Lambda表达式和理解 说明:部分资料来源于网络 时间:20190704 Lambda 表达式,也可称为闭包,它是推动 Java 8 发布的最重要新特性.Lambda 允许把函数作为一 ...

  3. WebDriver介绍

    Fetching a Page driver.get("http://www.google.com") Locating UI Elements (WebElements) By ...

  4. 123457123456---熊猫猜谜语02(儿童猜谜语大全)--com.threeObj03.CaiMiYu02

    熊猫猜谜语02(儿童猜谜语大全)--com.threeObj03.CaiMiYu02

  5. jQuery学习二

    1.id选择器: // 4.如果页面中多个元素id相同,jquery只会获取第一个id的jquery对象 var jquery = $('#name'); alert(jquery.val()); v ...

  6. SQL Server数据同步交换

    一.为了解决数据同步汇聚,数据分发,数据转换,数据维护等需求,TreeSoft将复杂的网状的同步链路变成了星型数据链路.     TreeSoft作为中间传输载体负责连接各种数据源,为各种异构数据库之 ...

  7. hadoop学习之路1--centos7群集安装

    一.              安装centos7 1.  设置硬盘为单文件40G.CPU 2核.内存2G.其他默认. 2.  安装时选择gnome,具备操作界面,并增加hadoop的账号. a)   ...

  8. php验证码实例

    验证码实例如下看不懂的先看gd库的那一篇,session不懂的看from提交的数据都哪里了那一篇,欢迎关注 index.php <!DOCTYPE html> <html lang= ...

  9. gitblit git SERVER window 安装配置 hook post-receive 自动部署

    项目中使用的是gitblit windos版 1.安装 需要JAVA SDK http://gitblit.com/Download Gitblit GO (Windows) 下载后,解压缩,放到例如 ...

  10. vue中的.passive修饰符

    一.passive作用 详情请参考MDN(https://developer.mozilla.org/zh-CN/docs/Web/API/EventTarget/addEventListener)中 ...