Link to home
Start Free TrialLog in
Avatar of JCWEBHOST
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
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

you should NOT try to "see" the next identity, at least not to display/use that.
only doing the insert, and then fetching the value using SCOPE_IDENTITY() is the correct (for multi.user apps anyhow) way to do
Avatar of JCWEBHOST
JCWEBHOST

ASKER

give an exsample please
ASKER CERTIFIED SOLUTION
Avatar of cyberkiwi
cyberkiwi
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
after you run the INSERT (I presume you know how to do that), you run:

select scope_identity()

Open in new window

Thanks