

That will mimic the full functionality of Oracle's MINUS command in SQL Server 2000 T-SQL. So, say you want to see this - between the 2 tables, find where students are missing AND students whose names have changed - either from A to B or from not null to null or from null to not null.Īnd (C.CNAME = G.CNAME or (C.CNAME is null and G.NAME is null) ) However, it will not work like Oracle's MINUS command to spot differences between tables. This will work to identify students in one table but not in another.

That is, the = operator does not address nulls. However, it is incomplete in that it does not address a curveball. While using MINUS clause, the following criteria must be satisfied: Number of columns in each SELECT statement should equal. It returns all records from the first result-set that do not appear in the second result-set. Thanks in advance for your time/comments.Ĭaution: Microsoft talks about this issue at. The SQL MINUS clause is used to compare the result-sets of two or more SQL SELECT statements. Here's a reference to the website where I initially found out about MINUS: If not supported, well then I guess I have to throw myself at the feet of the real SQL gurus and ask if there's another way to accomplish this.Is the MINUS capability supported by SQL Server? I know that there are all sorts of different SQL dialects & implementations and that SQL has evolved & transmutated over the years perhaps they opted to leave this out of SQL Server.So if CarType contains records with the keys. I read that there is an SQL " MINUS" keyword that you can use like this: there is no corresponding entry in the Cars table). Now I am trying to build a list of all those CarTypeId entries (from the CarType table) for which there are no Cars (i.e. Table Cars includes a column CarTypeId (int) which is a foreign key into the CarType table. Table CarType has a column CarTypeId which is the primary key (int, identity).

Maybe there's another better way to do this.
