--2個表比較DECLARE@SourceTableNameVARCHAR(100)DECLARE@DestTableNameVARCHAR(100)SET@SourceTableName="TableA"SET@DestTableName="TableB"SELECTA.TABLE_NAMEASSourceTable,A.COLUMN_NAMEASSourceColumn,A.DATA_TYPEASSourceType,B.TABLE_NAMEASDestTable,B.COLUMN_NAMEASDestColumn,B.DATA_TYPEASDestTypeFROM(SELECT*FROMINFORMATION_SCHEMA.COLUMNSWHERETABLE_NAME=@SourceTableName)AFULLOUTERJOIN(SELECT*FROMINFORMATION_SCHEMA.COLUMNSWHERETABLE_NAME=@DestTableName)BONA.COLUMN_NAME=B.COLUMN_NAMEANDA.DATA_TYPE=B.DATA_TYPEWHEREA.TABLE_NAMEISNULLORB.TABLE_NAMEISNULL
--2個表比較DECLARE@SourceTableNameVARCHAR(100)DECLARE@DestTableNameVARCHAR(100)SET@SourceTableName="TableA"SET@DestTableName="TableB"SELECTA.TABLE_NAMEASSourceTable,A.COLUMN_NAMEASSourceColumn,A.DATA_TYPEASSourceType,B.TABLE_NAMEASDestTable,B.COLUMN_NAMEASDestColumn,B.DATA_TYPEASDestTypeFROM(SELECT*FROMINFORMATION_SCHEMA.COLUMNSWHERETABLE_NAME=@SourceTableName)AFULLOUTERJOIN(SELECT*FROMINFORMATION_SCHEMA.COLUMNSWHERETABLE_NAME=@DestTableName)BONA.COLUMN_NAME=B.COLUMN_NAMEANDA.DATA_TYPE=B.DATA_TYPEWHEREA.TABLE_NAMEISNULLORB.TABLE_NAMEISNULL