I have a table in a test database that seems to get a little confused when I ran the INSERT scripts to set it up. The scheme is as follows:
ID UNIQUEIDENTIFIER TYPE_INT SMALLINT SYSTEM_VALUE SMALLINT NAME VARCHAR MAPPED_VALUE VARCHAR
It should have dozens of lines. It has about 200,000, most of which are duplicates in which TYPE_INT, SYSTEM_VALUE, NAME and MAPPED_VALUE are identical, but the identifier is not.
Now I could make a script to clear this file, which creates a temporary table in memory, uses INSERT .. SELECT DISTINCT to capture all the unique values, TRUNCATE original table and then copy everything back. But is there an easier way to do this, like a DELETE query with something special in a WHERE ?
sql sql-server-2008
Mason wheeler
source share