Results 1 to 3 of 3

Thread: best way to compare last row with new insert

  1. #1
    Join Date
    Apr 2006
    Posts
    178

    best way to compare last row with new insert

    Hi !
    for MS SQL 2000

    I need an UsersHistory Table where i cannot INSERT 2 rows one after the other with the same user.name

    I can get

    Bob
    David
    Bob


    but not

    Bob
    Bob
    David


    something like an INDEX on rows
    or
    INSERT INTO UsersHistory (name) VALUES ('bob') IF MAX(name) <> 'bob' ?

    what is the best way to do it ?



    thank you
    Last edited by anselme; 01-21-2007 at 01:59 AM.

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    Does the table have datetime or serial number column? If not, how do you know which row is last row?

  3. #3
    Join Date
    Apr 2006
    Posts
    178
    the last row is the last id (autoincrement) there is also a datetime column = getDate()

Posting Permissions

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