SQL Server - Get column lengths for same tables in two different schemas

Asked By Aryan Bhatt on 04-Mar-22 03:21 PM


I am having quite a few (~500) tables with same name but in different schemas i.e. 1) DWH and 2)REP
the column lengths for the above tables should ideally be the same in both the schemas, however that is not the case.

How do I write a SQL query that will give all those columns in the above 500 tables for which there is a mismatch in the column lengths.

e.g. DWH.Table1 col1 varchar(30), col2 varchar(200) and REP.Table1 col1 varchar(40), col2 varchar(255)

Any help would be much appreciated.