I am comparing two SQL server databases (development and live, SQL2005 and SQL2008, respectively) to check the differences between them. If I create a script for each database, I can use a simple text comparison to highlight the differences.
The problem is that the scripts should be in the same order to simplify the comparison and avoid simple differences when the order of the stored procedures is different, but their contents are the same.
So, if I create this from development:
1: CREATE TABLE dbo.Table1 (ID INT NOT NULL, Name VARCHAR(100) NULL) 2: CREATE TABLE dbo.Table2 (ID INT NOT NULL, Name VARCHAR(100) NULL) 3: CREATE TABLE dbo.Table3 (ID INT NOT NULL, Name VARCHAR(100) NULL)
And this is from the living:
1: CREATE TABLE dbo.Table1 (ID INT NOT NULL, Name VARCHAR(100) NULL) 2: CREATE TABLE dbo.Table3 (ID INT NOT NULL, Name VARCHAR(100) NULL) 3: CREATE TABLE dbo.Table2 (ID INT NOT NULL, Name VARCHAR(100) NULL)
Comparison of the two main lines 2 and 3 as different, but they are actually identical, only the script generation wizard made table3 before table 2 in a live environment. Add to 100 tables, stored procedures, views, etc., and it quickly becomes a mess.
My current settings are:
- Manually sort contents before comparing
- Create a scripting program in a specific order
- Find a free app that sorts your scripts
- Pay for a product that does this as part of its toolbox.
- (Another way to do it)
Hopefully I miss the checkbox that says “Sort scripts by name”, but I don’t see anything that does this. I don’t feel that I will have to pay for something as simple as the “sort” option or many other unnecessary tools, so option 4 should only be the last.
EDIT I have full access to both environments, but the live environment is locked and hosted on remote desktop virtual servers for normal access to live. My preference is to copy what I can, into development and compare there. I can generate scripts for each type of object in the database as separate files (tables, SP, functions, etc.).