日期:2014-05-17  浏览次数:21206 次

6万多条数据,删除符合条件,并上下衔接(高难度,附代码,高手指教一、二)
每个人下面左、右两边衔接了2个人,分别为LeftNumber、RightNumber。程爆炸性增长。现在整个网络里有一些人不符合条件ispayok=0,必须删除。HyParentNumber就是LeftNumber、RightNumber的接点人,程三角形式显示。
SQL   总数据达到6万5千条,需要吧不符合条件的删除,而且要吧整个网络衔接起来。现在无法删除,进度条到达38%的时候,差不多一个小时不动了。
那位高手能帮忙看看吗?感激不尽............


<%
set   HyExcelRs=nothing
set   HyExcelRs=server.CreateObject( "adodb.recordset ")
sql   =   "SELECT   HyID,HyNumber,LeftNumber,RightNumber   FROM   HyClub   where   ispayok=0     order   by   ID "
HyExcelRs.Open   sql,conn,1,1
if   HyExcelRs.RecordCount> 0   then
while   (not   HyExcelRs.eof)
HyNumber=HyExcelRs( "HyNumber ")
LeftNumber=HyExcelRs( "LeftNumber ")
RightNumber=HyExcelRs( "RightNumber ")
HyID=HyExcelRs( "HyID ")

if   LeftNumber= "0 "   or   RightNumber= "0 "   then
ChildNumber= "0 "
if   LeftNumber <> "0 "   then
ChildNumber=LeftNumber
end   if
if   RightNumber <> "0 "   then
ChildNumber=RightNumber
end   if

set   Temprs=nothing
set   Temprs=server.CreateObject( "adodb.recordset ")
sql   =   "select   *   from   hyClub   where   HyNumber   in   (select   HyParentNumber   from   hyClub   where   Hyid   =   "   &   HyID   &   ") "
Temprs.Open   sql,conn
kk=Temprs.recordcount
if   kk> 0   then
ParentID=Temprs( "ID ")
ParentNumber=Temprs( "HyNumber ")
if   Temprs( "LeftNumber ")=HyNumber   then
strsql= "update   HyClub   set   LeftNumber= ' "&ChildNumber& " '   where   ID= "   &   ParentID
else
strsql= "update   HyClub   set   RightNumber= ' "&ChildNumber& " '   where   ID= "   &   ParentID
end   if
set   rs1=server.CreateObject( "adodb.recordset ")
response.write   strsql& " <br> "
rs1.Open   strsql,conn

strsql= "update   HyClub   set   HyParentNumber= ' "&ParentNumber& " '   where   HyNumber= ' "   &   ChildNumber   & " ' "
set   rs1=nothing
set   rs1=server.CreateObject( "adodb.recordset ")
rs1.Open   strsql,conn
'response.write   strsql& " <br> "
end   if

set   rs=nothing
set   rs=server.CreateObject( "adodb.recordset ")
sql   =   "delete   from   hy   where   id   =   "   &   HyID
rs.Open   sql,conn
set   rs=nothing

set   rs=server.CreateObject( "adodb.recordset ")
sql   =   "delete   from   hyClub   where   Hyid   =   "   &   HyID
rs.Open   sql,conn
end   if

HyExcelRs.movenext
wend
end   if
%>

------解决方案-------------