sql c# 表数据去除重复记录

 #region 去重处理
        static public void Distinct(string tableName)
        {
            string sqlCmd = "  delete from tdly." + tableName +
                             "  where rowid in (select rid from(select rowid rid, row_number() " +
                             "  over(partition by " + getTablePrimeKey(tableName) + " order by rowid)" +
                             "  rn from tdly." + tableName + " ) where rn<> 1 ) ";
            WriteLogToFile("去重处理  sql:" + sqlCmd);
            if (Tool.ExecuteNonQuery(sqlCmd, strCnn) < 0)
            {
                WriteLogToFile("去重表" + tableName + "失败!");
            }
            else
            {
                WriteLogToFile("去重表" + tableName + "成功!");
            }
        }
发布了85 篇原创文章 · 获赞 7 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/guoruijun_2012_4/article/details/100124176