大掌柜剧情分集介绍:还是SQL语句的问题。

来源:百度文库 编辑:高校问答 时间:2024/05/10 12:00:18
<%@ LANGUAGE="VBScript" %>
<!--#include file="admin.asp"-->

<!--#include file="conn.asp"-->
<%

dim sql
dim rs
on error resume next

set rs=server.createobject("adodb.recordset")
sql="delete * from email where email not Like '%@%'"
rs.open sql,conn,1,1
set rs=nothing
conn.close
set conn=nothing
response.redirect "Manage_Book.asp"
%>
我用以上代码,实现了删除不含@字符的功能,现在想实现,删除重复数据的功能,即若字段email中有两条重复的数据,则删除其中的一条。(需保留一条)怎么书写呢?谢谢大家。
Robin_G,用了你提供的语句后,把我的整个数据库记录都删除了,还好我有备份:(

不好意思,当中没注意,写漏了点,Sorry!
下面是新的,本人测试过了,绝对好用!

感谢支持!!!

<!--#include file="admin.asp"-->

<!--#include file="conn.asp"-->
<%
Sql = "select distinct email into [#aaa] from [email]"
conn.execute(sql)

Sql = "drop table [email]"
conn.execute(sql)

Sql = "select * into [email] from [#aaa]"
conn.execute(sql)

Sql = "drop table [#aaa]"
conn.execute(sql)

%>

除了存储过程,俺也不知道怎么弄了,那位大虾知道拴变告诉俺一声哦 lovezkq@126.com

sql="select email from email order by email"
rs.open sql,conn,3,1
dim temp
rs.movefirst
temp=rs("email")
do while not rs.eof
rs.movenext
if rs.eof then exit do
if rs("email")=temp then
rs.delete
if rs.eof then exit do
rs.movenext
if rs.eof then exit do
else
temp=rs("email")
end if
wend