zoukankan      html  css  js  c++  java
  • 批量删除数据库中的字段

    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, "错误!");
                }
  • 相关阅读:
    判断分流使用
    Mac系统如何显示隐藏文件?
    Brew安装的软件查询安装位置
    JetBrains 产品线破解方法
    Linux查看与挂载新磁盘
    对BRD、MRD、PRD、FSD四类产品文档的理解
    网站收藏
    收藏
    官方文档
    java 的访问权限控制
  • 原文地址:https://www.cnblogs.com/Tonyyang/p/1209842.html
Copyright © 2011-2022 走看看