本文介绍了使用asp.net删除sql server 2008中的重复行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

你好家伙

我有两张桌子

一张是主桌子和

秒是DNC。

在主表中我有5列... id,name,phone_number,地址,城市

在DNC表中我只有一列是phone_number。



我必须做.....匹配两个表并从DNC中显示的主表中删除数据.....使用asp.net

请帮帮我.. ..

Hello guys
I have two table
one is main table and
second is DNC.
In main table I have 5 columns...id,name,phone_number,address,city
In DNC table I have only one column that is phone_number.

I have to do.....match two table and remove data from main table which is presented in DNC.....using asp.net
please help me....

推荐答案

public static void DeleteDuplicateEntry()
     {
         using (SqlConnection cn = new SqlConnection("YourConnectionStringName"))
         {
             SqlCommand objComm = new SqlCommand("delete from MainTable where phone_number in (select phone_number from DNC)", cn);
             objComm.CommandType = CommandType.Text;
             cn.Open();
             objComm.ExecuteNonQuery();
         }
     }


update Main SET phone_number = '' FROM main INNER JOIN DNC on Main.phone_number = DNC.phone_number


这篇关于使用asp.net删除sql server 2008中的重复行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-09 03:00