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
 General SQL Server Forums
 New to SQL Server Programming
 Whats the difference?

Author  Topic 

Topaz
Posting Yak Master

199 Posts

Posted - 2007-11-22 : 10:03:05
I've been writing a few sql queries over the past few days, and would like to know what the difference is between:

website is null

website like ''

Becasue if they mean different things i want to know how to look them both up at the same time. Obv im after data that is blank or has nothing written in it.

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-11-22 : 10:05:47
Null is not equal to blank or empty string. Null means nothing..that means absence of any value irrespective of data type. You can cover both condition to check data that is null or blank, you can do something like:

col is NULL or Col = ''


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Topaz
Posting Yak Master

199 Posts

Posted - 2007-11-22 : 10:09:25
so if i were to tidy things up, i could change all the fields that display null to ''?
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-11-22 : 10:15:09
Do you really want Nulls in the columns? If not, you can just make them non-nullable by adding NOT NULL constraint.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Topaz
Posting Yak Master

199 Posts

Posted - 2007-11-22 : 10:19:25
would it be bad practice if were to remove all the nulls?
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-11-22 : 10:25:50
It depends upon your business requirements whether you need NULLable columns or not. But if you are not well versed with the concept of NULL and NULL logic then it would be better to understand it first or you may get strange outputs in case of NULLs.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Topaz
Posting Yak Master

199 Posts

Posted - 2007-11-22 : 10:30:04
i see where you are coming from, i will leave the nulls alone...

thanks
Go to Top of Page
   

- Advertisement -