Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Find name of SQL Sequence

Posted on 2011-03-24
3
Medium Priority
?
452 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

722 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