zoukankan      html  css  js  c++  java
  • SQLSERVER 储存过程操作多行数据的几种方式

    对Table 表做操作 Table Table(表名),id(Table的自增字段),临时表的定义

    1. 用ID递增 去循环
      declare @id int =0
      while( (select top 1 id from Table where id>@id order by id)>0 )
      begin
       select @id=(select top 1 ostid from OutStockTask where ostid>@id order by ostid)--递增id 类似于for 中的i++
       select @id
      end
    2. 用临时表加while语句去循环
      declare @id int =0
      select id into #temp_Table from Table --创建临时表 
      while(exists(select * from Table where id not in(select id from #temp_Table)))--排除已操作过的数据id
      begin
          select @id=id from Table where not in(select id from #temp_Table) order by id--得到要操作的行数据id
          insert into #temp_Table--把做过操作的数据给到临时表
          select @id
      end
    3. 使用游标
    。net工程师
  • 相关阅读:
    androidactivity与webview结合
    anroid打包
    android之Fragment
    android布局
    anroid
    map reduce filter
    杂记
    spark记录
    Tomact和XML配置文件
    js-day02
  • 原文地址:https://www.cnblogs.com/yuners/p/13750557.html
Copyright © 2011-2022 走看看