Results 1 to 3 of 3

Thread: Just learning SQL Statements

  1. #1
    Join Date
    Nov 2008
    Posts
    3

    Just learning SQL Statements

    I want to create a select statement to where I would take a field, find the last number that was added to this field and then increment it by 1 to give me the next number.

    If I can get help on creating a select statement to find the last number that would help me so much.

    SELECT T0.[SuppSerial] FROM OSRI T0
    First this is the field name in [] and the table is the OSRI, any help would be great, thanks

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    If it is SQL Server you can recreate the table with the SuppSerial column defined as Identity and it will automatically increment when you insert data.

    Otherwise, you need to get max value of column and add 1 every time you insert and it can cause locking issue.

  3. #3
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    If you looking for just autonumbering then check this article. You could use co-related subquery to generate unique serial numbers.

    http://www.databasejournal.com/featu...ry-results.htm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •