這不是問過?
create proc P--存儲過程名 
asif object_id('Tempdb..#shop_snsn') is not null
drop table #shop_snsn
select
shop_snsn.cjname,bt.kucun
into #shop_snsn
from bt join shop_snsn on bt.isbn = shop_snsn.cjname and shop_snsn.shopclass=2 and shop_snsn.kucun <>bt.kucun
create index IX_#shop_snsn on #shop_snsn(cjname)
SET ROWCOUNT 200;
while exists(select 1 from #shop_snsn)
begin
update a
set kucun=b.kucun
from
shop_snsn a
join
#shop_snsn b on a.cjname=b.cjname and a.shopclass=2
delete b from shop_snsn a join #shop_snsn b on a.cjname=b.cjname and a.shopclass=2 and a.kucun=b.kucun
end
SET ROWCOUNT 0goexec P

解决方案 »

  1.   

    呵呵~我的asp页面是这样的!
    <!--#include file="conn.asp"-->
    <!--#include file="adminset.asp"-->
    <%if session("admin")="" then
    response.Write "<script language='javascript'>alert('网络超时或您还没有登陆!');window.location.href='login.asp';</script>"
    response.End
    end if
    if qx1<>1 then
    response.Write "<div align=center><font size=80 color=red><b>您没有此项目管理权限!</b></font></div>"
    response.End
    end if
    %>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>统一图书库存数目</title>
    </head><body>
    <table width="100%" border="0" cellpadding="0" cellspacing="0" background="images/right_top2.gif">
      <tr>
        <td width="1%">&nbsp;</td>
        <td width="99%"><table width="100%" border="0" cellspacing="0" cellpadding="5">
            <tr>
              <td width="30%" style="font-size:14px;color:#ffffff">&nbsp;<strong><font color="#000000">统一图书库存数目</font></strong></td>
              <td width="70%" align="right">&nbsp;</td>
            </tr>
        </table></td>
      </tr>
    </table>
    <br>
    <% dim action
       action=trim(request.QueryString("action"))
       
       select case action
       case ""
    %>
    <form name=="form1" action="new_kucun.asp?action=modify" method="post">
    <table width="80%" border="0" cellpadding="0" cellspacing="0" background="images/right_top2.gif" align="left">
      <tr>
        <td width="1%">&nbsp;</td>
        <td width="99%"><table width="100%" border="0" cellspacing="0" cellpadding="5">
            <tr>
              <td width="30%" style="font-size:12px;color:#ffffff" height="30" align="center">&nbsp;<strong><font color="#000000">本操作将BT上有,我们的网站上也有的图书,库存数目统一成BT上的图书库存数目</font></strong></td></tr>
      
              <td width="70%" align="center" height="30"><input name="submit" type="submit" value="统一库存数目"></td>
            </tr>
        </table></td>
      </tr>
    </table>
    </form>
    <%
      case "modify"
      dim kucun,isbn,cjname,shopclass
      
      kucun=trim(request("kucun"))
      isbn=trim(request("isbn"))
      cjname=trim(request("cjname"))
      shopclass=trim(request("shopclass"))
     
      conn.execute("update shop_snsn set kucun=bt.kucun from bt join shop_snsn on bt.isbn like                 shop_snsn.cjname and shop_snsn.shopclass=2 ")
      response.Write "<script language='javascript'>alert('更改成功!');window.location.href='new_kucun.asp';</script>"
      response.End
      end select
    %>
    </body>
    </html>
    怎么调这个啊 ?
      

  2.   

    Create Proc P_test
    as 
    if object_id('Tempdb..#shop_snsn') is not null 
    drop table #shop_snsn 
    select 
    shop_snsn.cjname,bt.kucun 
    into #shop_snsn 
    from bt join shop_snsn on bt.isbn = shop_snsn.cjname and shop_snsn.shopclass=2 and shop_snsn.kucun <>bt.kucun 
    create index IX_#shop_snsn on #shop_snsn(cjname) SET ROWCOUNT 200; 
    while exists(select 1 from #shop_snsn) 
    begin 
    update a 
    set kucun=b.kucun 
    from 
    shop_snsn a 
    join 
    #shop_snsn b on a.cjname=b.cjname and a.shopclass=2 
    delete b from shop_snsn a join #shop_snsn b on a.cjname=b.cjname and a.shopclass=2 and a.kucun=b.kucun 
    end 
    SET ROWCOUNT 0