comparing two tables

I have two identical table ie all the columns are identical and one of the datatype is Text, one is varchar(255) and the rest are int.
Lets say the table name is ‘AAAAA’.
Table AAAAA was processed and backed up earlier this month.
Both the tables were storing data and now the second table is only storing data.
I need to find unmatching records from the second table (BBBBB) which is storing data right now and add those records to Table AAAAA.

Your help will be highly appreciated. I tried to use ‘EXCEPT’ but it does not support text datatype.

  • Inserting Image to MS SQL Server
  • Inserting the SQL query result in Excel
  • How to use CASE in the WHERE clause
  • Why SP gives slightly different result than SELECT statement with same filters
  • sql geography to dbgeography?
  • Does rebuild index do the equivalent of dropping and recreating the indexes?
  • I’m using SQL Server 2005.

    4 Solutions collect form web for “comparing two tables”

    Get a copy of redgate’s SQL Data Compare.

    If you’re using Visual Studio 2010 Premium or above you can use the data compare tool.

    Answer to marks question: The Primary key is the combination of 6 fiels/columns.

    Can’t you just do a left join using your primary key fields the rows with null values for your ‘AAAAAA’ table will be null.

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.