通过下面的语句 SELECT Name FROM SYSCOLUMNS WHERE ID = OBJECT_ID('yourtable1')可以得到yourtable1的所有字段,你将这些字段插入到一个临时表, 临时表可以create #table (id int identity, fieldname varchar(30)), 假如你的表的字段有30个的话,采用两层游标对两个表中的数据和30个字段进行循环,就可以比较了.三少 :o)

解决方案 »

  1.   

    我已知兩表的名稱和字段,临时表也做好了,用你說的有點慢(可能有10000條記錄---ACCESS庫).
      

  2.   

    select * 
       from table2 
       where not exist (select * 
                            from table1
                            where table1.column1=table2.column1 and
                                  table1.column2=talbe2.column2 and
                                  ...
                        )
    union 
    select * 
       from table1 
       where not exist (select * 
                            from table2
                            where table1.column1=table2.column1 and
                                  table1.column2=talbe2.column2 and
                                  ...
                        )