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, "错误!");
                }
  • 相关阅读:
    向量空间模型 词袋模型
    python 小点
    python list的append()和extend()方法
    numpy 数组运算
    内置函数和numpy中的min(),max()函数
    python index()函数
    Python支持的正则表达式元字符和语法
    Python多线程
    查看linux机器配置&内核版本
    Shell获取文件的文件名和扩展名的例子
  • 原文地址:https://www.cnblogs.com/Tonyyang/p/1209842.html
Copyright © 2011-2022 走看看