Wednesday, December 30, 2009

How to use MINUS operator in MsSql as opposed to Oracle

How to get result of one sql and subtract the result of another sql dynamically in MsSql server. If you are aware of the MINUS keyword used in oracle.

like
select emp_id from employee where dept='MANUFACTURING'
minus
select emp_id from employee where
emp_ctgry='SUPERVISOR'

This will list out the employees which are not under
SUPERVISOR category.
How to do similar job in MsSql, where you can not use MINUS as it is not MsSql specific ?
The answer is you will need to use 'EXCEPT' keyword, which is equivalent to MINUS in Oracle.
I'm not very sure but as per my knowledge MsSql 6.5 does not support MINUS operator.


No comments:

SpringBoot: Features: SpringApplication

Below are a few SpringBoot features corresponding to SpringApplication StartUp Logging ·          To add additional logging during startup...