Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Find name of SQL Sequence

Posted on 2011-03-24
3
Medium Priority
?
458 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 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

926 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