Solved

Find name of SQL Sequence

Posted on 2011-03-24
3
417 Views
Last Modified: 2012-05-11
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

 Screenshot
0
Comment
Question by:Gaz124
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 35205848
actually, the Sequences here are are not "system" of SQL Server, like the identity field would be.
so, there is no way to know which sequence would go into which table unless the relation sequence-table is stored somewhere.
it is hence only used in application code, so you cannot know it from that data you showed.

question: why use such a sequence object if you could use IDENTITY?
0
 
LVL 7

Expert Comment

by:mkobrin
ID: 35205850
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
0
 

Author Comment

by:Gaz124
ID: 35206029
Thanks angellll, at least I know im not going nuts now. I'll  contact the application writers.

mkobrin - I think you misunderstood the question
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now