sql - DATALENGTH() or ISNULL() to retrieve fields that are not null and not empty -
quite simply, of following methods better in where clause retrieve records field_name not null , not empty
where datalength(field_name) > 0 or
where isnull(field_name, '') <> '' update
i have been informed first method gives spurious results types of fields... agree?
firstly,
select * table column <> '' will give same results as
select * table isnull(column, '') <> '' because records condition unknown rather false still filtered out. go first option.
datalength counts trailing spaces, comparison '' not. whether want ' ' compare unequal ''. if do, need datalength. if don't, compare ''.
note text/ntext types, comparisons not supported, datalength is.
Comments
Post a Comment