Link to home
Start Free TrialLog in
Avatar of Gaz124
Gaz124Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Find name of SQL Sequence

I'm currently trying to write an insert query for a db and want to get the next value from a sequence for one of the insert fields.
The only problem is I don't know what the sequence is called! I can query the table and see the sequences in there but I cant find out the actual name of the sequence??

If anyone could help that would be great

 User generated image
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg 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
Avatar of mkobrin
mkobrin

After the insert statement select the @@Identity field eg:

insert into a (a,b,c) values (1,2,3)
select @@identity as newID

will insert the record and return the new id in a field called newID
Avatar of Gaz124

ASKER

Thanks angellll, at least I know im not going nuts now. I'll  contact the application writers.

mkobrin - I think you misunderstood the question