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 2008 Forums
 Transact-SQL (2008)
 Find Records where a field is null or empty

Author  Topic 

CoffeeAddict
Yak Posting Veteran

94 Posts

Posted - 2010-04-22 : 15:54:17
Trying to pull all orders where cash is null OR empty

select * from order
where order.ash_code ...
and type = 'car'

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-04-22 : 16:10:02
[code]select * from order
where order.ash_code is null or order.ash_code = ''[/code]
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-04-22 : 16:10:05
where isnull(column,'') = ''


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

CoffeeAddict
Yak Posting Veteran

94 Posts

Posted - 2010-04-22 : 16:19:18
yes I've already tried the is null or = '' and I get this and not really sure ...it's complaining about the datatype differences that I'm comparing:

The data types text and varchar are incompatible in the equal to operator.
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-04-22 : 16:28:37
Your data type seems to be text. Its better you change it to a varchar data type.

This should work for you.
select * from order
where order.ash_code is null or order.ash_code like ''
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-04-23 : 01:27:03
where isnull(convert(varchar(max),order.ash_code),'') = ''



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -