Monday, 1 July 2013

GENERIC 1. New Tables and Views

USE DBName2
GO
SELECT DISTINCT TABLE_SCHEMA,TABLE_NAME FROM [DBName1].INFORMATION_SCHEMA.TABLES A
WHERE TABLE_NAME NOT IN (
SELECT DISTINCT TABLE_NAME COLLATE SQL_Latin1_General_CP1_CI_AS FROM DBName2.INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA COLLATE SQL_Latin1_General_CP1_CI_AS = A.TABLE_SCHEMA AND TABLE_TYPE COLLATE SQL_Latin1_General_CP1_CI_AS = A.TABLE_TYPE
)
AND TABLE_TYPE = 'BASE TABLE'
ORDER BY TABLE_SCHEMA,TABLE_NAME

No comments:

Post a comment