想将一段ASP代码用一个存储过程实现

cx_hzgdj 2007-04-26 10:11:56
我是想将以下ASP中的代码,转成SQL存储过程,前辈们帮帮忙,学习:

<%
strSql="select id,nsort1,filename from upload where id>1 and id<=1000 order by id"
set rs=conn.Execute(strSql)
if rs_1.eof and rs_1.bof then

else
do while not rs_1.eof
select case rs_1("nsort1")
case "article"
strSql="select 1 from article where charindex('"&rs_1("filename")&"',word)>0"
case "forum"
strSql="select 1 from bbs_data where charindex('"&rs_1("filename")&"',word)>0"
Case Else
strSql=""
end select
If strSql<>"" then
set rs=server.createobject("adodb.recordset")
rs.open strSql,conn,1,1
If rs.RecordCount>0 Then
strSql=""
Else
conn.execute("update upload set iid=0,types=0 where id="&rs_1("id"))
End If
rs.close:set rs=Nothing
End if
rs_1.movenext
loop
rs_1.close:set rs_1=Nothing
end if
%>
...全文
130 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
---涛声依旧--- 2007-04-26
  • 打赏
  • 举报
回复
在ASP裡調用樓上的存儲過程就行了
chuifengde 2007-04-26
  • 打赏
  • 举报
回复
create proc testProc
as
declare @id int
declare @file varchar(100),@ns varchar(100)
declare cur cursor for
select id,nsort1,filename from upload where id>1 and id<=1000 order by id
open cur
fetch next from cur into @id,@ns,@file
while @@fetch_status=0
begin
if @ns='article' or @ns='forum'
begin
exec('select 1 from article where charindex('''+@file+''',word)>0')
if @@rowcount=0
update upload set iid=0,types=0 where id=@id
end
fetch next from cur into @id,@ns,@file
end
close cur
deallocate cur

34,587

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧