[Info-ingres] why is an empty string an integer

Paul White paul.white at shift7solutions.com.au
Wed Jul 29 08:56:06 UTC 2020


Hi Marty,

I expect the result of "a is integer" should align to the result of
int(a).

Compare with MSSQL with some doubtful results.

create table #fred(
   a varchar(20));

insert into #fred values (null), (''), ('1'), ('1.0'), ('13-jan-2020');

select case when a is null then 'null'
            when a = '' then 'empty string'
            else a end as data,
  case when try_convert(numeric,a) is null then '' else 'Y' end as Is_Num,
  case when try_convert(int,a) is null then '' else 'Y' end  as is_int,
  case when try_convert(float,a) is null then '' else 'Y' end  as is_float,
  case when try_convert(money,a) is null then '' else 'Y' end  as Is_money,
  case when try_convert(datetime,a) is null then '' else 'Y' end  as is_date
  from #fred;

data                 Is_Num is_int is_float Is_money is_date
-------------------- ------ ------ -------- -------- -------
null
empty string                Y      Y        Y        Y
1                    Y      Y      Y        Y
1.0                  Y             Y        Y
13-jan-2020                                          Y

(5 rows affected)

Paul White
&
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.planetingres.org/pipermail/info-ingres/attachments/20200729/c0639e1d/attachment.html>


More information about the Info-ingres mailing list