大秦之暗夜君王无弹窗:VB中如何判断 sql数据库中的表是否已经存在?

来源:百度文库 编辑:中科新闻网 时间:2024/05/14 03:29:40
能写个完整的语句吗,谢谢了

比较笨的方法是从sql语句里建立一个到该表的连接,如果表不存在,err.description就是“表或视图不存在”

select name from sysobjects where xtype='u' and name='table1'
如果有记录则存在,没有记录则不存在

<%
tablename="table1"
sql="select name from sysobjects where xtype='u' and name='"+tablename+"'"
rs.open sql,conn,0,1
if rs.eof then
response.write "不存在"
else
response.write "存在"
end if
%>