Hi all,
I have a datatable Employee which is containg columns Emp_ID, Emp_Name, Manager_ID
I want to retrieve all the rows whose Manager_ID=NULL
I wirte the query select * from Employee where Manager_ID=NULL
but it is not working. How to do this. Please help me.
with regards
Ravinder Reddy.K
You have to use IS operator on NULL..
select * from Employee where Manager_ID is NULL
remember,
NULL = NULL => always False
NULL IS NULL = > True
|||
>NULL = NULL => always False
Not always... this is dependent on the setting of ANSI_NULLS. Try the following as an example:
SET ANSI_NULLS ON
GO
SELECT CASE WHEN NULL = NULL THEN 'YES'
ELSE 'NO'
END
GO
--Result: 'No'
SET ANSI_NULLS OFF
GO
SELECT CASE WHEN NULL = NULL THEN 'YES'
ELSE 'NO'
END
GO
--Result: 'Yes'
Chris
||| Forget the Settings BUDDY
No comments:
Post a Comment