"Peter Neumaier" <Pe************ @gmail.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
Hi!
I got a column, with different dates in it (Ddata type "nvarchar") ...
when running a SELECT on this column, I'm trying to filter those
recordsets out, WHERE this column is NULL (I checked the table, there
are "empty" fields in the column):
"SELECT bla FROM bla WHERE myColumn NOT NULL"
but I still receive those "empty" fields in my resultset ...
so I tried it with:
SELECT bla FROM bla WHERE myColumn <> ''
again, "empty" fields in my resultset ....
what's going wrong there? is there a possibility to check what kind of
value I got in my column!?
Thanks!
Peter
As a guess, you want this:
select *
from dbo.MyTable
where coalesce(SomeCo lumn, '') <> ''
See COALESCE() and ISNULL() in Books Online. If this doesn't help, I suggest
you post an example of the 'empty' data - is it empty strings, a number of
spaces etc. You can use LEN(), DATALENGTH(), ASCII() etc to help identify
the data.
You should also change the column data type to datetime, not nvarchar, as
that will help prevent invalid data (eg empty strings) and also allow you to
use datetime functions like DATETIME and DATEADD more easily.
Simon