Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2016
    Posts
    12
    Provided Answers: 1

    Unanswered: Using a Primary Key to use in a WHERE statement or similar

    Can I get the current record PK from one table and compare it with a field in another table.

    For example WHERE Table 1 PK (last record entered) = Table 2 Field

    Many thanks

  2. #2
    Join Date
    Oct 2007
    Posts
    161
    Provided Answers: 9
    yes, you just add the predicates that find the last record entered to your SQL

  3. #3
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,862
    Provided Answers: 17
    "Last record" is not really a thing in SQL Server. Tables represent un-ordered sets. You can try adding a monotonically rising attribute (like an Identity column), or a created date column, but these have various pluses and minues (especially around concurrency).

  4. #4
    Join Date
    Jul 2016
    Posts
    12
    Provided Answers: 1
    Quote Originally Posted by MCrowley View Post
    "Last record" is not really a thing in SQL Server. Tables represent un-ordered sets. You can try adding a monotonically rising attribute (like an Identity column), or a created date column, but these have various pluses and minues (especially around concurrency).
    Thanks for your reply

  5. #5
    Join Date
    Dec 2016
    Posts
    8
    Primary Keys is very important in SQL you should get all the Keys which is use in SQL server https://www.janbasktraining.com/blog...-example-uses/

Tags for this Thread

Posting Permissions

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