Distinct rows in a DataTable

  • Thread starter Thread starter Rajiv Lingayat
  • Start date Start date
R

Rajiv Lingayat

Hi,

Which is the best way to copy all the distinct rows from one data table
to another data table?

Thanks,
Rajiv
 
I've looked and I don't believe there is any easy way to filter a datatable
or view so it only contains distinct rows; that being the case, you would
have to implement code to pick just one of a set of duplicate rows, which
would be cumbersome.

I think the easiest thing to do is to just fill a DataTable with a "SELECT
DISTINCT" query from your datasource, unless it's an extremely expensive
query. Then, of course, you can simply merge the rows with the other
datatable.

Steven Bras, MCSD
Microsoft Developer Support/Data Access Technologies

This posting is provided "AS IS" with no warranties, and confers no rights.

Microsoft Security Announcement: Have you installed the patch for Microsoft
Security Bulletin MS03-026?  If not Microsoft strongly advises you to
review the information at the following link regarding Microsoft Security
Bulletin MS03-026
http://www.microsoft.com/security/security_bulletins/ms03-026.asp and/or to
visit Windows Update at http://windowsupdate.microsoft.com to install the
patch. Running the SCAN program from the Windows Update site will help to
insure you are current with all security patches, not just MS03-026.
 
Back
Top