Generate and retrieving Next sequential Customerid

Posted on 2009-04-30
Last Modified: 2012-05-06
There is a need for me to  list all customerid plus e next sequential CustomerId. in this table the customerid is not a primary key. I think a subquery should. How can i modify the below query to achieve this
select Distinct Customer_Id from customers

from (select MAX (Customer_Id) + 1 from customers where CUSTOMER_ID <> 999 )

Open in new window

Question by:Projack
    LVL 75

    Accepted Solution

    select MAX (Customer_Id) + 1 from customers
    SELECT Customer_id from Customers
    LVL 22

    Assisted Solution

    What if the table is updated after you query it? What if the next inserted row gets rolled back or deleted? Your assumption about the next sequential Id may be incorrect. Whether that matters or not depends on how you are using the information.

    Author Closing Comment

    Thanks for your advice. It is admin moduleand only one operator use that page per time

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
    How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    779 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

    12 Experts available now in Live!

    Get 1:1 Help Now