Table comparisons TSQL

  • Hi all

    Can someone please advise me on a problem I have with table comparisons.

    I have

    and

    which are both have the explicit field names listed and works as intended, however, when I try to test this in a test db I get an error message as follows:

    "Explicit calling of field names have been used, which are not yet applied to test, and so will not be applied on live. The script failed".

    At the moment I have used the following select statement example:

    SELECT Min(Table_Name) AS ALIAS, Field 1, Field 2, Field 3, Field 4, Field 5, Field 5,

    etc

    FROM(

    SELECT 'Table_Name' AS ALIAS, Field 1, Field 2, Field 3, Field 4, Field 5, Field 5, etc

    FROM Table_Name

    WHERE NOT EXISTS

    (

    SELECT 1 FROM Table_Name_backup

    WHERE Table_Name.fieldname = Table_Name_backup.fieldname

    )

    UNION ALL -- verified as ALL

    SELECT 'Backup' AS Table_Name_backup, Field 1, Field 2, Field 3, Field 4, Field 5, Field 5, etc

    FROM Table_Name_backup

    WHERE NOT EXISTS

    (

    SELECT 1 FROM Table_Name

    WHERE Table_Name_backup.fieldname = Table_Name.fieldname

    )

    ) tmp

    group by Field 1, Field 2, Field 3, Field 4, Field 5, Field 5, etc

    having count(*) = 1

    order by fieldname

    Can someone advise on how i could possibly use the (select * from) instead of explicitly?

  • create a view out of this.

  • Hi

    I understand what a view is but can you elaborate a bit more on what you mean. I have been trying to incorporate the select * statement instead of the explicit naming of fields but was getting an error stating dbo. prefixes as a problem.....

    Your thoughts would be much appreciated .......

    Thanks

Viewing 3 posts - 1 through 2 (of 2 total)

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