Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Matching 2 databases schemas

Author  Topic 

dtrivedi
Posting Yak Master

153 Posts

Posted - 2011-05-18 : 07:54:42
My boss asked me to match two diffrent databases schema. what is the easiest way to start doing this?

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2011-05-18 : 08:02:27
Redgate's SQL Compare
http://www.red-gate.com/products/sql-development/sql-compare/

Go to Top of Page

dtrivedi
Posting Yak Master

153 Posts

Posted - 2011-05-18 : 08:14:08
unfortunately due to firewall issues i can't download this...is there an original way to do this?
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-05-18 : 08:19:15
You can use the inforfation_schema views
Also could script the two databases (probably be object) and do a compare on the result

In both cases ou will have to decide on what is important - e.g. index/default names - easier to ignore with the views.



==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

dtrivedi
Posting Yak Master

153 Posts

Posted - 2011-05-18 : 09:34:21
can you be more specific?
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2011-05-18 : 09:47:43
ask your boss what he wants to compare

are the databases on the same server?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

dtrivedi
Posting Yak Master

153 Posts

Posted - 2011-05-19 : 08:12:41
no they are not on the same server. He wants to compare the schema because one of the datbases has new data that the other doesn't have
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-05-19 : 08:55:51
Information_schema.tables gives a list of tables
Information_schema.columns gives a list of columns
....

You can usea linked server to access the other server and compare.

>> one of the datbases has new data that the other doesn't have
Do you want to compare data or schema?

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

dtrivedi
Posting Yak Master

153 Posts

Posted - 2011-05-19 : 10:06:24
the schema has changed because of the data
Go to Top of Page

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2011-05-19 : 10:09:59
You need to compare data NOT schema. You can use EXCEPT and INTERSECT for this purpose.

--------------------------
http://connectsql.blogspot.com/
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-05-19 : 10:16:49
quote:
Originally posted by dtrivedi

the schema has changed because of the data



Still not sure what you want.
If it's the schema changes then you can do it using the information_schema views.

If it's data changes to common tables/columns then you can join on the PKs and compre the attribute column values.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2011-05-19 : 10:32:49
hey lion...every hear of vendors building database that dynamically buyild database objects based of new data?

For example if a "New" Company comes in on a load, they build a table for that company, instead of having a company column

it is what is...give a monkey a gun



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -