Select that does not return blank SQL

0
select 'TEM' AS InSituacao
    from GTCLogist
where NrPlacaCarreta = ''
and ID <> '35514'
and year(DtBase)=year(GETDATE())
and MONTH(DtBase)=MONTH(GETDATE())
and DAY(DtBase)=DAY(GETDATE())

I have the above SQL, I need when the field is blank, I do not get anything back. I already tried isnull but since the field is blank and not null I do not know if I made the correct use.

    
asked by anonymous 17.04.2017 / 13:59

1 answer

1

Kevin, consider the following suggestion:

-- código #1 v2
declare @Hoje date;

set @Hoje= cast(current_timestamp as date);

SELECT ID, NrPlacaCarreta, 'TEM' as InSituacao
  from GTCLogist
  where coalesce(ltrim(NrPlacaCarreta), '') <> ''
        and ID <> '35514'
        and cast(DtBase as date) = @Hoje;

Code # 1 does not return rows in which the NrPlaccarPort column is either blank (NULL) or empty or has blank space (s).

    
17.04.2017 / 15:19