Jes Sie

Jes Sie

  • 737
  • 1.2k
  • 284.4k

What is the best way of counting rows in sql server?

Apr 26 2021 1:37 AM
Hello everyone, I have a query that counts the total inserted rows in the SQL server. I added 1 to get the new row that should be inserted. See my query below:
  1. SELECT COUNT(CustomerID) + 1  
  2.     FROM fmCustomer   
  3.     WHERE year(getLogs) = YEAR(GETDATE())  
But, here is the weird thing that always happens:
 
As you can see, it jumps from 21-00251 to 21-00253. Any suggestions on how can I count total rows + 1? Thanks in advance.