Bit of a "Newbie" question. Compare and join databases.

  • I like doing things through system tables:

    SET NOCOUNT ON;

    SELECT

    'SELECT [SpecificationColumns]' + CHAR(13) + CHAR(10) +

    'FROM PRODUCTIONCopy.dbo.' + name + CHAR(13) + CHAR(10) +

    'EXCEPT SELECT [SpecificColumns]' + CHAR(13) + CHAR(10) +

    'FROM PRODUCTION.dbo.' + name + CHAR(13) + CHAR(10) + CHAR(13) + CHAR(10)

    FROM sys.tables

    WHERE name NOT IN ('sysdiagrams');

    SELECT

    'SELECT [SpecificationColumns]' + CHAR(13) + CHAR(10) +

    'FROM PRODUCTION.dbo.' + name + CHAR(13) + CHAR(10) +

    'EXCEPT SELECT [SpecificColumns]' + CHAR(13) + CHAR(10) +

    'FROM PRODUCTIONCopy.dbo.' + name + CHAR(13) + CHAR(10) + CHAR(13) + CHAR(10)

    FROM sys.tables

    WHERE name NOT IN ('sysdiagrams');

    SET NOCOUNT OFF;

    Set SSMS output to text, run it, copy the result pane to the query pane, run it again. And Robert's your mother's brother.

    -----
    [font="Arial"]Knowledge is of two kinds. We know a subject ourselves or we know where we can find information upon it. --Samuel Johnson[/font]

Viewing post 16 (of 15 total)

You must be logged in to reply to this topic. Login to reply