您的位置:程序门 -> web 开发 -> asp



更新数据库信息的问题


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


更新数据库信息的问题[已结贴,结贴人:cloudgamer]
发表于:2007-05-16 16:27:56 楼主
我有大概30万条的数据要更新
用什么方法好呢

我现在的方法是
for   id=1   to   20000
set   rs=toconn.EXECute( "select   content   from   "&mdbtable& "   where   info_id= "&id)
if   not   rs.eof   then
sstr=rs(0)
rstr=sstr
rstr=check(rstr)
if   rstr <> sstr   then
toconn.EXECute( "update   "&mdbtable& "   set   content= ' "&rstr& " '   where   info_id= "&id)
response.write(id& " <br> ")
response.flush()
end   if
end   if
next

但效率还是比较慢
5分钟才1000条
谁有更好的办法啊
发表于:2007-05-16 16:37:421楼 得分:5
一句sql就可以了,   如果还慢,看下索引的位置对不对
update   table   set   content= 'xxx '   where   info_id   > =   1   and   info_id   <=2000   and   content   <>   "xxxxxx "
发表于:2007-05-16 16:40:372楼 得分:0

用一句怎么取内容出来处理啊
发表于:2007-05-16 16:51:573楼 得分:0
可能的话,可以在sql   server上自定义check函数,   全部在数据库上解决,不用往返20000次了
发表于:2007-05-16 18:08:014楼 得分:5
5分钟1000条是很慢
update   [dbo].[table1]   as   t1   set   item1=t2.itema   from   [dbo].[table2]   as   t2   where   t1.someitem=t2.specifieditem

好像有条类似的语句可以,好久没有用了,忘却了。


快速检索

最新资讯
热门点击