try
{
ArrayList sqlList = new ArrayList();
string StrSqlTables = "select d.name,a.name FROM syscolumns a left join systypes b on a.xtype=b.xusertype " +
" inner join sysobjects d on a.id=d.id and d.xtype='U' and d.name<>'dtproperties' " +
" and a.name = 'rowguid' ";
string StrSql = "";
string table_NAME = "";
DataSet ds = DbHelperSQL.Query(StrSqlTables);
foreach (DataRow row in ds.Tables[0].Rows)
{
table_NAME = row.ItemArray[0].ToString();
StrSql = "ALTER TABLE " + table_NAME + " DROP COLUMN rowguid ; ";
sqlList.Add(StrSql);
}
DbHelperSQL.ExecuteSqlTran(sqlList);
MessageBox.Show("删除成功", "提示!");
}
catch (Exception ex)
{
MessageBox.Show("删除失败 "+ex.Message, "错误!");
}
{
ArrayList sqlList = new ArrayList();
string StrSqlTables = "select d.name,a.name FROM syscolumns a left join systypes b on a.xtype=b.xusertype " +
" inner join sysobjects d on a.id=d.id and d.xtype='U' and d.name<>'dtproperties' " +
" and a.name = 'rowguid' ";
string StrSql = "";
string table_NAME = "";
DataSet ds = DbHelperSQL.Query(StrSqlTables);
foreach (DataRow row in ds.Tables[0].Rows)
{
table_NAME = row.ItemArray[0].ToString();
StrSql = "ALTER TABLE " + table_NAME + " DROP COLUMN rowguid ; ";
sqlList.Add(StrSql);
}
DbHelperSQL.ExecuteSqlTran(sqlList);
MessageBox.Show("删除成功", "提示!");
}
catch (Exception ex)
{
MessageBox.Show("删除失败 "+ex.Message, "错误!");
}
欢迎转载,转载请注明出处:http://www.cnblogs.com/Tonyyang/