September 2010
Intermediate to advanced
1704 pages
111h 8m
English
One common problem encountered with imported data is unexpected duplicate data rows, especially if the data is being consolidated from multiple sources. In previous versions of SQL Server, de-duping the data often involved the use of cursors and temp tables. Since the introduction of the ROW_NUMBER ranking function and common table expressions in SQL Server 2005, you are able to de-dupe data with a single statement.
To demonstrate this approach, Listing 43.26 shows how to create an authors_import table and populate it with some duplicate rows.
Listing 43.27 Script to Create and Populate the authors_import Table
You can see in the data for Listing 43.27 that there are two duplicates for au_id 499-84-5672 ...