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. C#-片段:外侧代码

    ylbtech-C#-片段:外侧代码 1.返回顶部 ·#if #if true #endif ·#region #region MyRegion #endregion ·namespace names ...

  2. Java体系

    Java之父:詹姆斯·高斯林 java之前叫做“Oak”,后改名为Java.//Oak来源于橡树,java 来源爪哇岛的一种咖啡 Java语言平台 J2SE(Java 2 Platform Stand ...

  3. 阶段5 3.微服务项目【学成在线】_day16 Spring Security Oauth2_09-SpringSecurityOauth2研究-Oauth2密码模式授权

    密码模式(Resource Owner Password Credentials)与授权码模式的区别是申请令牌不再使用授权码,而是直接 通过用户名和密码即可申请令牌. 测试如下: Post请求:htt ...

  4. matlab学习——05插值和拟合(黄河小浪底调水调沙问题)

    05插值和拟合 黄河小浪底调水调沙问题 data3.txt 1800 1900 2100 2200 2300 2400 2500 2600 2650 2700 2720 2650 32 60 75 8 ...

  5. LeetCode_38. Count and Say

    38. Count and Say Easy The count-and-say sequence is the sequence of integers with the first five te ...

  6. 设置滑动TabBar的显示和隐藏

    代码如下: //设置滑动的判定范围 - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint ...

  7. localStorage 存储 数组

    let str = JSON.stringify(data.list); localStorage.setItem("options",str); let optionss=loc ...

  8. 性能优化-Bitmap内存管理及优化

    Bitmap作为重要Android应用之一,在很多时候如果应用不当,很容易造成内存溢出,那么这篇文章的目的就在于探讨Bitmap的有效运用及其优化 缓存介绍 当多次发送请求的时候,请求同一内容,为了使 ...

  9. jquery-easyui中改变【确认框控件的按钮文字】($.messager.confirm)

    根据API这句话,就很自然想到重写该方法,代码如下: $.messager.defaults = { ok: "通过", cancel: "不通过" ,widt ...

  10. nginx 为什么受欢迎?

    优势:1.高并发 2.可扩展性 3.高可靠性 4.热部署 5.BSD许可证 如何做到以上优势呢?高并发:异步io非阻塞,占用更少资源,支持更多连接可扩展:模块化设计,第三方模块多高可靠:核心框架代码的 ...