--当表中不存在text、ntext、image、cursor这些类型的字段时,可以使用如下语句比较两个表中的数据是否完全相同if not exists(select * from 表一 where checksum(*) not in (select checksum(*) from 表二)) and not exists(select * from 表二 where checksum(*) not in (select checksum(*) from 表一)) print '数据相同' else print '数据不同'
and not exists(select * from 表二 where checksum(*) not in (select checksum(*) from 表一))
print '数据相同'
else
print '数据不同'