在数据库中,添加数据表,比如说,我要添加一个名称为a的数据表,但我不知道数据库中是否存在名称为a的数据表,如有,就删除,否则就添加,用sql实现???

解决方案 »

  1.   

    select * from sysobjects where name='YourTableName' and xtype='U' 查询表是否存在
      

  2.   

    xtype='U' 
    这是什么意思??
      

  3.   

    xtype='U' 类型为用户表select * from sysobjects where name='YourTableName' and xtype='U' 这样做的前提是你数据库连接字符串中设置的数据库是你的表所在的数据库
      

  4.   

    sql = "select * from sysobjects where id=' xxqfpmmm 'and xtype='U'set rs=cnn.execute (sql)然后判断rs(0)为空是吗?我这里好象出错了,
    错误提示是:
    实时错误: -2147217913(80040e07)
    syntax error converting the varchar value 'xxqfpmmm'
    to a column of data type int怎么回事?
      

  5.   

    http://expert.csdn.net/Expert/FAQ/FAQ_Index.asp?id=8159