Search code examples
c#sqlmax

SQL query SELECT MAX return value is 9 but the total rows is 10. When the ID reaches 10 it seems it doesn't count the ID 10


I programmatically auto increment my supplier id using max when inserting the agents becasue my supplier table consist of distributors which are manually encoded id and agent is auto increment. My supplier id data type is nvarchar. Help me what seems to be the problem, When the id reaches 10 it seems it doesn't count the ID 10

This is the image

I tried count but the problem in count is when some of the record is deleted.


Solution

  • Oh i got it. I just need to cast the ID to int.