Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 ansi_nulls

Author  Topic 

Sh12345
Starting Member

4 Posts

Posted - 2015-04-10 : 17:15:01
I want to turn on ansi_null so I won't get records with null
in the results.
The query :
SET ANSI_NULLS ON
GO
select [ProductID], [Color]
from [Production].[Product]
WHERE [Color] IS NULL
GO

The results:
ProductID Color
1 NULL

and I still get records with null in the results ..
What is wrong?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2015-04-10 : 17:21:37
WHERE Color IS NOT NULL

Or maybe I'm not understanding what you want.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

Sh12345
Starting Member

4 Posts

Posted - 2015-04-11 : 04:54:36
I have an example of another query with ansi_nulls:

http://xpode.com/ShowArticle.aspx?ArticleId=599

in this example the ansi_nulls are on and it returns 0
for all the records where the value is null...
In my query i did the same - I turned on the ansi_nulls
and I have "color" column where I have null values .
And I still didnt get 0 , I got records with nulls..
So..
dont know what...is wrong

tnx for the response



quote:
Originally posted by tkizer

WHERE Color IS NOT NULL

Or maybe I'm not understanding what you want.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/

Go to Top of Page
   

- Advertisement -