超时在sql server问题中过期

时间:2010-03-31 06:55:50

标签: sql-server-2005 asp-classic ado

set con2=server.CreateObject("ADODB.Connection")
con2.ConnectionTimeout =1200
con2.open "Driver={SQL Server};server=111.111.111.11;user id=xx;pwd=xxx;Database=xxx"
con2.execute("DELETE FROM tablename WHERE fieldid NOT IN(SELECT fieldid FROM tablename2)")
con2.close
set con2=nothing

当我使用asp运行此查询时发生以下错误。如何解决这个问题?

  

用于ODBC的Microsoft OLE DB提供程序   驱动程序错误'80040e31'

     

[Microsoft] [ODBC SQL Server   驱动程序]超时已过期

1 个答案:

答案 0 :(得分:1)

不使用not in,而是使用left join

delete from tablename
left join tablename2 on tablename2.fieldid = tablename.fieldid
where tablename2.fieldid is null