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. pgpool 的配置文件详解

    listen_addresses = 'localhost' # Host name or IP address to listen on: # '*' for all, '' for no TCP/ ...

  2. VS中卸载Visual Assist X

    Tools=>Extensions and updates=>找到Visual Assist X 卸载:

  3. ISO/IEC 9899:2011 条款6.4.8——预处理数字

    6.4.8 预处理数字 语法 1.pp-number: digit .    digit pp-number    digit pp-number    identifier-nondigit pp- ...

  4. 解决Jmeter跨线程组取参数值难题!(还没试)

    来源 https://mp.weixin.qq.com/s/q7ArxwnX1sOfa9tfHouSBQ 如果你工作中已经在用jmeter做接口测试,或性能测试了,你可能会遇到一个麻烦.   那就是j ...

  5. mysql数据format格式化错误

    DROP TABLE IF EXISTS `api_billing`; CREATE TABLE `api_billing` ( `id` ) NOT NULL AUTO_INCREMENT, `se ...

  6. iis启动异常 0x80072749

    错误提示: “/”应用程序中的服务器错误. 无法向会话状态服务器发出会话状态请求.请确保 ASP.NET State Service (ASP.NET 状态服务)已启动,并且客户端端口与服务器端口相同 ...

  7. laravel服务提供者类说明

    IoC 是将内部设计的类交给系统去控制,但是有些类在初始化的时候,需要制定特定的参数,或者当你需要将实现类绑定到某个接口,这时候就必须对这些依赖进行配置,系统才能正确解析并引用. register 而 ...

  8. 【Leetcode_easy】628. Maximum Product of Three Numbers

    problem 628. Maximum Product of Three Numbers 题意:三个数乘积的最大值: solution1: 如果全是负数,三个负数相乘还是负数,为了让负数最大,那么其 ...

  9. git rev-parse介绍;获取commit id

    git rev-parse master^{commit} 是什么意思 显示master提交的SHA1值 if you want to make sure that the output actual ...

  10. Python sys.path永久添加

    在用户目录下,找到隐藏文件.bashrc 或 .zshrc 文件然后在末尾添加 export PYTHONPATH=$PYTHONPATH:/home/dev/custom_path 操作:vim . ...