Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2003
    Posts
    41

    Unanswered: getting a constraint value from query in a trigger?

    say i have a query like:

    UPDATE table SET status = 1 WHERE id = 1000

    if i have a trigger on that table, is there anyway i can get the id ?

    i know i can get the status by SELECT status FROM Inserted, but anyway to get what the id is? or would i just have to update the id as well?

    thanks

  2. #2
    Join Date
    Dec 2003
    Posts
    41
    hmm, looks like i can't even get the id if i try to update since it's an identity column

  3. #3
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    How about:
    Code:
    SELECT id FROM inserted
    -PatP

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    inserted AND deleted are full blown copies of the table that's affected for the rows that are be modified or added.

    You [Id] should be there

    What are you trying to do?
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  5. #5
    Join Date
    Dec 2003
    Posts
    41
    oops, actually i just realized SELECT id from inserted works fine even though id isn't updated

    thanks

Posting Permissions

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