You are here
The following is one approach to removing duplicate records from a table assuming the first entry is the one to keep.
FROM dbo.contact c1
INNER JOIN( SELECT emailaddress, MIN(contactid) AS contactid
GROUP BY emailaddress
HAVING COUNT(*) > 1
) c2 ON c1.emailaddress = c2.emailaddress
WHERE c1.contactid > c2.contactid
About the Author:
With the new ADO.NET 2.0 DbProviderFactory and DbProviderFactories classes, you can change the database provider at runtime. The DbProviderFactories class is use to create a factory object, which in turn is use to create the appropriate provider objects (connection, command, dataadapter, etc). Here's an example that returns a DbConnection object based on the name of the connection string in the Web.config file.
/// Create generic database connection object using new DbProviderFactories class.
The following query converts a column of data in a SQL table to a comma-delimited string. This works great for tables with a few hundred rows and limited to the size of the VARCHAR data type. A TEXT field can also be use if needed for large tables, but requires a little more work.