Click here to Skip to main content
15,914,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to compare the database schema of two databases in SQL server?Is there any query or stored procedure to find it out?
Posted

There are a number of free and paid tools available.

Here[^] is a list of some good tools.

You can also have a look at SQL Server Schema Comparison Tool in Visual Studio 2010[^].
 
Share this answer
 
Comments
maestro_88 8-Aug-11 5:23am    
Thanks Abhinav for your response.Is there any query to find it out?
 
Share this answer
 
There is no easy way to do this using stored procedure or query. You can try querying sys schema that contains all meta data about database.

For example you can get object definition for stored procedures like this

SQL
select OBJECT_SCHEMA_NAME(P.object_id) as [Schema], P.name as [Procedure Name] ,c.text as Procedure_Definition
from sys.procedures P
inner join sys.syscomments C on P.object_id = C.id


Using this query you can join two database tables and select those where database1.sys.syscomments.text is not qual to database1.sys.syscomments.text

Another option is to use a third party tool such as ApexSQL Diff or any similar tool on the market.
 
Share this answer
 
Comments
CHill60 28-Jun-13 17:24pm    
The question is over a year old !
By "compare" perhaps you mean "find a short cut avoiding nested SELECT"?
USE [database]
GO
SELECT * FROM INFORMATION_SCHEMA.SCHEMATA

Shows CATALOG_NAME & SCHEMA_NAME. Having those two bits of info makes a WHERE clause more useful. Especially since the SCHEMA is named. Xreference sys.objects or other sys. procedures in an EXEC clause. Etc.

Also quite a few other "View" INFORMATION_SCHEMA items to oconnsider. See BOL.
 
Share this answer
 
Comments
CHill60 28-Jun-13 17:23pm    
<quote>By "compare" perhaps you mean "find a short cut avoiding nested SELECT ... nope I think he meant "compare" ... over a year ago

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900