JCWEBHOST
asked on
Sql indentity
hey guys, i need an sql query to find the indentity, the hard part is when the table is empty it returning value of 2
select IDENT_CURRENT('Customer') + IDENT_INCR ('Customer')
i am looking for the next indentity, if the table is empty return 1 and if 1 record is inserted the sql statement must return 2 and so on
select IDENT_CURRENT('Customer') + IDENT_INCR ('Customer')
i am looking for the next indentity, if the table is empty return 1 and if 1 record is inserted the sql statement must return 2 and so on
ASKER
give an exsample please
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
after you run the INSERT (I presume you know how to do that), you run:
select scope_identity()
ASKER
Thanks
only doing the insert, and then fetching the value using SCOPE_IDENTITY() is the correct (for multi.user apps anyhow) way to do