Figure 3.11 shows the new record count for the SQL_Conn table, a mere 32 records.. Figure 3.13 shows the 5 fields from the SQL_Conn table that I used to guarantee uniqueness.. I am heart
Trang 1uniqueness, the clustered index will be a composite of the package run date and several other fields I will also add an identity column (ID) to the tables
Since the tables currently contain duplicate rows, in this example, I will first need
to clean up a bit by truncating both the SQL_Conn and SQL_Conn_Archive I can then run the package to populate the SQL_Conn table with current process information Figure 3.11 shows the new record count for the SQL_Conn table, a mere 32 records
Figure 3.11: Repopulated SQL_Conn table ready for merging data
The SQL_Conn_Archive table currently holds zero records, as we would expect, clean slate and all Figure 3.12 shows the empty table, in preparation for the prestidigitation to follow
Trang 2Figure 3.12: Empty SQL_Conn_Archive table
So, now I am going to add the clustered index and an identity column (ID) to both tables Figure 3.13 shows the 5 fields from the SQL_Conn table that I used to guarantee uniqueness I am heartened by the fact that, as this table fills up over time, the clustered index will also benefit me when running interrogative queries for reports of sever activity
Figure 3.13: Building clustered index for SQL_Conn table
Trang 3It compares one table at a time and displays the differences between the two tables Further, it can generate scripts that will sync the two tables, if there are differences For SQL Server 2005, Tablediff.exe can be found in the C:\Program Files\Microsoft SQL Server\90\COM\ folder It has options that allow you to define the source and destination servers, as well the required databases and tables Listing 3.6 shows the command line execution that will compare the freshly loaded SQL_Conn source table and the destination SQL_Conn_Archive The options -q and -t 200, respectively, tell tablediff to do a simple record count rather than a full blown compare, and to timeout after 200 seconds You also have the ability to lock the source and target tables, as I am doing here with
-sourcelocked and –destinationlocked
C:\Program Files\Microsoft SQL Server\90\COM\tablediff.exe" -sourceserver MW4HD1 -sourcedatabase DBA_Rep -sourcetable
SQL_Conn -sourcelocked -destinationlocked -destinationserver MW4HD1 -destinationdatabase DBA_Rep -destinationtable
SQL_Conn_Archive -q -t 200
Listing 3.6: Tablediff with source and destination options
Figure 3.14 shows the 32 records that are different in SQL_Conn and
SQL_Conn_Archive tables, by doing a simple row count It took less than a tenth
of a second to deliver the results
Trang 4Figure 3.14: Tablediff.exe row count differences
Without the -q option, you will get a list of differences, by ID column, as shown
in Figure 3.15 This comparison took 0.15 seconds for the 32 records
Figure 3.15: Tablediff showing detailed differences
Trang 5SQL_Conn.sql file that the command created
Figure 3.16: Output of fix file for Tablediff.exe
Executing the script against the SQL_Conn_Archive table and then re-running the tablediff.exe will show that the two tables are now identical
"High Availability" tools
Finally, we move on to a discussion of what I have termed "high availability" data migration tools, simply because these tools generally form part of an organizations strategy in minimizing downtime and maximizing the availability of its data
Up to now we have been working with single source tables, whereas these techniques are more applicable when whole databases need to be migrated, and