Solved

How to compare Database tables / schema in SQL Server 2005 ?

Posted on 2011-02-17
4
556 Views
Last Modified: 2012-06-27
Hi All,

Is it possible to create or do it from SSMS to compare two different schema ?

I need to compare database table in my current production DB to see which one is different in order to generate delta (upgrade script)

Thanks.
0
Comment
Question by:jjoz
  • 2
  • 2
4 Comments
 
LVL 40

Expert Comment

by:Sharath
ID: 34922413
What exactly you want to compare? Do you want to check the no. of tables in one schema to another schema or between two databases?
0
 
LVL 1

Author Comment

by:jjoz
ID: 34922434
'Do you want to check the no. of tables in one schema to another schema or between two databases?"
yes exactly or even better the time last accessed or used by someone.

because I'm not sure which one is safe to delete at the moment.
0
 
LVL 40

Accepted Solution

by:
Sharath earned 500 total points
ID: 34922511
-- This query gives the no. of tables in each Schema. You need to run this both on Production and your dev server for same database to check the no. of tables
select TABLE_SCHEMA,COUNT(*) TableCount from INFORMATION_SCHEMA.TABLES group by TABLE_SCHEMA
-- You can get the last modified date of a table with the below query
select * from sys.tables order by modify_date desc

Open in new window

0
 
LVL 1

Author Closing Comment

by:jjoz
ID: 34931994
many thanks man !
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question