I have 21 DBs on same server which are 'supposed' to have the same schema (limiting schema only to table schema as of now) but they don't. In the environment I am, I can not install any tool/applications as per the compliance rules. The only way I can think of, is to pull up the schema of all the 21 DBs in excel and compare but its tedious.
Can someone guide me in developing a T-SQL which can compare the schema for all 21 DBs and highlight the differences?
These are the columns I need: Table_Name ,Column Name, Data type, Max Length, is_nullable, is_replicated, Primary Key
The following T-sql pulls up this in information for me. I need some idea about how can I compare this information for 21 DBs
SELECT a.name Table_Name, c.name 'Column Name',
t.Name 'Data type',
c.max_length 'Max Length',
c.is_nullable,a.is_replicated ,
ISNULL(i.is_primary_key, 0) 'Primary Key'
FROM Sys.tables a inner join sys.columns c
On A.object_id=C.object_id
INNER JOIN
sys.types t ON c.user_type_id = t.user_type_id
LEFT OUTER JOIN
sys.index_columns ic ON ic.object_id = c.object_id AND ic.column_id = c.column_id
LEFT OUTER JOIN
sys.indexes i ON ic.object_id = i.object_id AND ic.index_id = i.index_id
Order by 1,2
I need a starting point