如何循環刪除臨時表?
name = tbb[i]关键是这里不知道如何写
for( int i=1;i<=8;i++)
{
string yu7= "select count(*) from sysobjects where name = tbb[i] and type = 'U' ";
            SqlCommand gh7 = new SqlCommand(yu7, con);
            
            if((int)gh7.ExecuteScalar() >= 1) 
            { 
                SqlCommand tb7 = new SqlCommand("drop table tbb[i] ", con);      
                tb7.ExecuteNonQuery();
            } 
}

解决方案 »

  1.   

    name = tbb + cast(i as nvarchar(16))
      

  2.   


    for( int i=1;i<=8;i++)
    {
        string yu7= "select count(*) from sysobjects where name = tbb"+i.ToString()+" and type = 'U' ";
                SqlCommand gh7 = new SqlCommand(yu7, con);
                
                if((int)gh7.ExecuteScalar() >= 1) 
                { 
                    SqlCommand tb7 = new SqlCommand("drop table tbb"+i.ToString()+" ", con);      
                    tb7.ExecuteNonQuery();
                } 
    }
      

  3.   

    name = tbb"+i.ToString()+" 可以获取到表名,但删除不了。难道for循环不行?