既然你已经知道判断表存在与否的方法,那么我只写如果不存在就输出“表不存在”字样的大致sql写法if(表不存在)
 select '表不存在'

解决方案 »

  1.   

    -- 判断要创建的表名是否存在
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[表名]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
     print '不存在'
    GO
      

  2.   

    那个我是要在asp.net 中实现,按两位的方法试了还是不行呢
      

  3.   

    既然你已经知道怎样用sql判断表不存在,在asp.net里面if (表不存在)
    {Response.Write("表不存在");}
    else
    {Response.Write("表存在");}是这样吗?
      

  4.   

    Try:1.new a stored procedure name "sp_checktable";
    create procedure sp_checktable
      @tablename nvarchar(50)
    as
       begin
     
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[表名]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
       select 0
    else
       select 1
       end
    2.c# code:
    SqlConnection conn=new SqlConnection(connectionstring);
    SqlCommand cmd=new SqlCommand("sp_checktable",conn);
    cmd.CommandType=CommandType.StoredProceture;
    conn.Open();
    SqlDataReader reader=cmd.ExecuteReader();
    int i=-1;
    if(reader.Read())
       i=int.Parse(reader[0].ToString())
    if(i==0)
      Response.Write("table is  not exists");
    else if(i==1)
      Response.Write("table is exists")
      

  5.   

    还可以count(*)  0就没有1就是有嘛