-1

How do i determine what the next value is of the Primary Key Auto increment?

I have been looking in the system databases but i couldnt find any answers.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Wvs
  • 45
  • 1
  • 9

1 Answers1

1

I am guessing you mean "the next value to be assigned to an identity column", and your identity column also happens to be used as a primary key. Otherwise, there is no concept in Sybase ASE that would qualify as "Primary Key Auto increment".

Assuming the above, you can get the next value to be assigned by using the function next_identity('table_name'). Note that the result is in varchar format so you may need to convert it back to a number.

RobV
  • 2,263
  • 1
  • 11
  • 7
  • Thanks Rob! When i do `SELECT next_identity('tablename')` it returns (NULL) also when i try to CAST it to int it returns `NULL` Any ideas? – Wvs Nov 09 '18 at 14:07
  • That means your table does not actually have an identity column. Check with sp_help. – RobV Nov 11 '18 at 10:38