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.
| Author |
Topic |
|
nguyenl
Posting Yak Master
128 Posts |
Posted - 2009-03-06 : 13:55:08
|
| Hi,I have 2 databases on the same server. DBA and DBB are suppose to be identical( have same triggers, function, procedures, tables, etc.....) Is there a way for me to do a table count comparison of these 2 databases and then have it tell me which tables have different counts?Thanks |
|
|
guptam
Posting Yak Master
161 Posts |
Posted - 2009-03-06 : 14:09:17
|
| If you want to do full Schema Compare with code an etc; then you'll need to use like RedGate Compare, or ApexSQL Compare.For simplying getting table count listing:SQL 2005:SELECT COUNT(*) FROM sys.tables SQL 2000:SELECT COUNT(*) FROM sys.objects WHERE xtype = 'U'To get column information:SQL 2005:SELECT T.name,count(*) AS ColumnCount FROM sys.tables t, sys.columns c WHERE t.object_id = c.object_idGROUP BY t.nameSQL 2000:SELECT T.name,count(*) AS ColumnCount FROM sys.sysobjects o, sys.columns c WHERE o.object_id = c.object_id AND o.xtype = 'U'GROUP BY t.name-- Mohit K. GuptaB.Sc. CS, Minor JapaneseMCITP: Database AdministratorMCTS: SQL Server 2005http://sqllearnings.blogspot.com/ |
 |
|
|
|
|
|