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, "错误!");
                }
  • 相关阅读:
    调度器2—cat /proc/<pid>/sched内容分析
    调度器1—相关接口和命令行工具
    Java中的String类
    Java中的数组
    代码访问使用Let's Encrypt证书的网站提示certificate has expired的解决方法
    Linux环境Clion使用Protobuf
    PyTorch Dataloader读取时如何在进程之间传输数据
    6 安装Grafana 展示promethues数据
    5 Prometheus relabel配置
    4 PromQL
  • 原文地址:https://www.cnblogs.com/Tonyyang/p/1209842.html
Copyright © 2011-2022 走看看