Query in an empty table

Asked

Viewed 281 times

1

What is the return of a query in an empty table?

Example, I am running this SQL Command:

select Value
  from AVL_AnalogInput1
 where TimeStamp = (select max(TimeStamp) from AVL_AnalogInput1) .

Table AVL_AnalogInput1.

inserir a descrição da imagem aqui

Outcome of the consultation.

inserir a descrição da imagem aqui

My question is, what kind of result are you returning to me? Are you returning me null? Or are you simply not returning anything to me? I can use this result to check if the table is empty?

  • I think this one link can help you

  • Note that your table is not empty, it contains a row with NULL values. NULL has a very specific behavior, especially in comparisons.

1 answer

1


See @@rowcount to see if you returned any lines in SELECT execution.

-- código #1
SELECT Value
  from AVL_AnalogInput1
  where TimeStamp = (select max(TimeStamp) from AVL_AnalogInput1);

IF @@rowcount = 0
  PRINT 'nada a declarar';

Details in @@rowcount.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.