1

What is the return code from SQL if you execute a SELECT COUNT(*) from ... and a count of 0 is returned? Is it 0 or 100 (not found)?

Thank you.

RBarryYoung
  • 55,398
  • 14
  • 96
  • 137
Rob
  • 11
  • 1
  • 2

3 Answers3

2

It will always return 1 row with 1 column (containing the number of rows i.e. the count(*) value), if that is what you are asking....

M.R.
  • 4,737
  • 3
  • 37
  • 81
0

Zero because there were no rows. What would 100 have to do with it?

Please look at my answer here too: Does COUNT(*) always return a result?

Edit: unless you mean DB2 as noted elsewhere...

Community
  • 1
  • 1
gbn
  • 422,506
  • 82
  • 585
  • 676
  • @BoltClock, @squillman: return code is zero. As I said, what does 100 have to do with it? There is no "not found" in SQL generally. Your comments are almost as bad as the question... – gbn Apr 27 '11 at 19:40
  • 1
    Well yeah given that OP didn't even specify what DBMS... I'm guessing it's IBM DB2. See http://en.wikipedia.org/wiki/DB2_SQL_return_codes – BoltClock Apr 27 '11 at 19:44
0

Assuming you are talking about MS SQL Server, the @@error code will always be 0 assuming you query a valid table. The @@error code is describing the success of the action itself, not the success of the results.

squillman
  • 13,363
  • 3
  • 41
  • 60
  • return codes can be set only by RETURN or internal errors. There is no return code for a SELECT COUNT. Do you mean @@ERROR? – gbn Apr 27 '11 at 19:42