Is there a way in SQL Server to compare entire row of one table with another table which has same data types.
Example开发者_Python百科:
CREATE TABLE [DBO].[PRODUCT]
(
[PID] [INT] NULL,
[NAME] [NCHAR](10) NULL,
[PDID] [INT] NULL
)
select * from product p, product c where p.{entirerow} = c.{entirerow}
is there some kind of option here?
Use SQL INTERSECT(all matching rows) and EXCEPT (all different rows), here for example:
SELECT * FROM Table1 INTERSECT SELECT * FROM Table2
SELECT * FROM Table1 EXCEPT SELECT * FROM Table2
You can compare subsets of columns by replacing * with a column list or subsets of rows by using a WHERE clause.
One caveat is that the schema's of the tables need to be the same.
精彩评论