if object_id('IMS.dbo.表1') is not null 
  print 'exit'
else
  print 'not exit'string SQL = ????SqlCommand myCommand = new SqlCommand(SQL,myConnection);
myConnection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close();

解决方案 »

  1.   

    string SQL = "select val=case when object_id('IMS.dbo.表1') is not null then 1 else 0 end  ";
      

  2.   

    还是不明白,怎么得到并保存这个结果,  bool a =  ???
      

  3.   

    insert into 你的表 你的字段 values (select val=case when object_id('IMS.dbo.表1') is not null then 1 else 0 end )
    SQL沒有bool值得概念,只可以用0,1來表示
      

  4.   

    SELECT CAST(ISNULL(object_id('IMS.dbo.表1'), 0) AS bit)这样得到的是 bit 型, 就是 C# 中的 System.Boolean 类型
      

  5.   

    string SQL = "SELECT CAST(ISNULL(object_id('IMS.dbo.表1'), 0) AS bit)";
    SqlCommand myCommand = new SqlCommand(SQL, myConnection);
    myCommand.Connection.Open();
    bool a = (bool)myCommand.ExecuteScalar();
    myCommand.Connection.Close();