obrech
asked on
what can I use in SQL 2000 for "Not in" command that works only in SQL2005
I cannot run this script in the SQL server 2000. The not in does not exist in SQL2000. What statement can I run instead. i need to retrieve records only from tblemp table that do not exists in ActiveDirectoryAllUsers table.
can you please write the example for me ( I am not a programmer)
I have the following error when I run this statment "Msg 116, Level 16, State 1, Line 1 Only one expression can be specified in the select list when the subquery is not introduced with EXISTS."
Thank you.
can you please write the example for me ( I am not a programmer)
I have the following error when I run this statment "Msg 116, Level 16, State 1, Line 1 Only one expression can be specified in the select list when the subquery is not introduced with EXISTS."
Thank you.
select emp_no, emp_Fname, emp_Lname, emp_MI
from tblemp
where emp_no not in
(select emp_no, emp_Fname, emp_Lname, emp_MI
from tblemp as e, ActiveDirectoryAllUsers as a
where e.emp_no = a.employeeID
)
Try:
select emp_no, emp_Fname, emp_Lname, emp_MI
from tblemp
where emp_no not in
(select emp_no
from tblemp as e, ActiveDirectoryAllUsers as a
where e.emp_no = a.employeeID
)
or:
select emp_no, emp_Fname, emp_Lname, emp_MI
from tblemp
where not exists
(select emp_no, emp_Fname, emp_Lname, emp_MI
from tblemp as e, ActiveDirectoryAllUsers as a
where e.emp_no = a.employeeID
)
select emp_no, emp_Fname, emp_Lname, emp_MI
from tblemp
where emp_no not in
(select emp_no
from tblemp as e, ActiveDirectoryAllUsers as a
where e.emp_no = a.employeeID
)
or:
select emp_no, emp_Fname, emp_Lname, emp_MI
from tblemp
where not exists
(select emp_no, emp_Fname, emp_Lname, emp_MI
from tblemp as e, ActiveDirectoryAllUsers as a
where e.emp_no = a.employeeID
)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:)
slight chnage on the exists() one:
select emp_no, emp_Fname, emp_Lname, emp_MI
from tblemp t
where not exists
(select emp_no
from tblemp as e, ActiveDirectoryAllUsers as a
where e.emp_no = a.employeeID and t.emp_no = e.emp_no --need this part.
)
slight chnage on the exists() one:
select emp_no, emp_Fname, emp_Lname, emp_MI
from tblemp t
where not exists
(select emp_no
from tblemp as e, ActiveDirectoryAllUsers as a
where e.emp_no = a.employeeID and t.emp_no = e.emp_no --need this part.
)
from tblemp
where emp_no not in
(select emp_no
from tblemp as e, ActiveDirectoryAllUsers as a
where e.emp_no = a.employeeID
)