CREATE PROC P_COMPDB @DB1 SYSNAME, --第一个库 @DB2 SYSNAME --第二个库 AS EXEC(' SELECT 类型=CASE ISNULL(A.XTYPE,B.XTYPE) WHEN ''V'' THEN ''视图'' ELSE ''存储过程'' END ,匹配情况=CASE WHEN A.NAME IS NULL THEN ''库 ['[email protected]+'] 中无'' WHEN B.NAME IS NULL THEN ''库 ['[email protected]+'] 中无'' ELSE ''结构不同'' END ,对象名称=ISNULL(A.NAME,B.NAME) FROM( SELECT A.NAME,A.XTYPE,B.COLID,B.TEXT FROM ['[email protected]+']..SYSOBJECTS A,['[email protected]+']..SYSCOMMENTS B WHERE A.ID=B.ID AND A.XTYPE IN(''V'',''P'') AND A.STATUS>=0 )A FULL JOIN( SELECT A.NAME,A.XTYPE,B.COLID,B.TEXT FROM ['[email protected]+']..SYSOBJECTS A,['[email protected]+']..SYSCOMMENTS B WHERE A.ID=B.ID AND A.XTYPE IN(''V'',''P'') AND A.STATUS>=0 )B ON A.NAME=B.NAME AND A.XTYPE=B.XTYPE AND A.COLID=B.COLID WHERE A.NAME IS NULL OR B.NAME IS NULL OR ISNULL(A.TEXT,'''')<>ISNULL(B.TEXT,'''') GROUP BY A.NAME,B.NAME,A.XTYPE,B.XTYPE ORDER BY 类型,匹配情况,对象名称') GO
时间: 2024-10-05 10:36:50