April 27, 2012 at 11:28 am
Dear Friends,
I am planning to compare database objects from Multiple Instances. Details are given below:
1. Instance ABC have around 10 Databases and 1000 objects
2. Instance XYZ have around 10 Databases and 700 objects
How to find missing 300 objects in XYZ instance?
Your quick help will be highly appreciated.
Regards,
Paul
April 27, 2012 at 12:16 pm
Honest answer here, if I had to do that, I'd use the command-line utility built into SQL Compare from Red Gate. It's the easiest way I know to make this happen in a timely & efficient manner.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
April 27, 2012 at 12:35 pm
Thank for your response.
I am looking at SQL Script with the combination of Linked Server.
I am not familiar with Redgate and there will be licencing issue to use in my company.
April 27, 2012 at 12:43 pm
I second the use of SQLCompare. It will likely work out cheaper to buy a license than to develop in-house.
If you absolutely must do custom dev, maybe a C#/VB app and use the SMO libraries. T-SQL comparisons will be difficult and tedious (been there, done that). If you're solely wanting to see what's in one place and not the other, that's pretty easy. If you need to compare teh definitions, see what's different between objects on the two instances that's very complex to do properly.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 30, 2012 at 8:57 am
Thank You Gila,
I am trying to workaround in TSQL using linked server as getting SQLCompare at this point will be difficult and I can't wait for long. The logic I am trying is given below:
Bring all the Database Objects of ABC instance to 1 single table
Bring all the Database Objects of XYZ instance to 1 single table
use simple join with not equal to condiation
April 30, 2012 at 9:08 am
Are you solely trying to see what objects are on one instance and not the other? No checks for whether objects named the same have the same definition, no checks for objects with the same definition but different names?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 30, 2012 at 9:14 am
Yes. Only trying to see what objects are on one instance and not the other. That is what is my requirement. Please let me know if you have better option than what I mentioned above without using any other tool.
April 30, 2012 at 9:25 am
What you suggest will work.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 30, 2012 at 9:26 am
pawana.paul (4/30/2012)
Yes. Only trying to see what objects are on one instance and not the other. That is what is my requirement. Please let me know if you have better option than what I mentioned above without using any other tool.
just basic objects?
something like this seems to work for me:
--returns items existng on Sandbox that are not in Test
SELECT SCHEMA_NAME(SCHEMA_ID),name,type_desc
FROM DEV223.Sandbox.sys.objects
WHERE is_ms_shipped=0
AND type_desc IN ( 'SQL_SCALAR_FUNCTION', 'CLR_SCALAR_FUNCTION', 'CLR_TABLE_VALUED_FUNCTION', 'SQL_INLINE_TABLE_VALUED_FUNCTION',
'SQL_STORED_PROCEDURE', 'CLR_STORED_PROCEDURE', 'RULE', 'SQL_TABLE_VALUED_FUNCTION',
'USER_TABLE', 'VIEW' )
EXCEPT
SELECT SCHEMA_NAME(SCHEMA_ID),name,type_desc
FROM DEV223.Test.sys.objects
WHERE is_ms_shipped=0
AND type_desc IN ( 'SQL_SCALAR_FUNCTION', 'CLR_SCALAR_FUNCTION', 'CLR_TABLE_VALUED_FUNCTION', 'SQL_INLINE_TABLE_VALUED_FUNCTION',
'SQL_STORED_PROCEDURE', 'CLR_STORED_PROCEDURE', 'RULE', 'SQL_TABLE_VALUED_FUNCTION',
'USER_TABLE', 'VIEW' )
Lowell
April 30, 2012 at 10:04 am
Thanks for the script. This script is for comparision of database objects with 2 databases on same instance and database names are coded. Is it possible to use MSforeachDB stored procedure for both the instances so that I can get the comparision in single query execution. If yes, please provide me the script.
April 30, 2012 at 10:11 am
Create a utilities database on each server. Use MSForEachDB on both instances to create insert a list of all objects in all databases into a table in tht utilities database, then use Lowell's code to compare them
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 30, 2012 at 10:56 am
Thanks Gail and Lowell for your help. Let me try using both of your logic / code.
Pawana Paul
Viewing 12 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply