VB中如何判断 sql数据库中的表是否已经存在?

来源:百度知道 编辑:UC知道 时间:2024/04/29 16:59:38
能写个完整的语句吗,谢谢了

比较笨的方法是从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
%>