Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Posts
    134

    Unanswered: trigger, inserted pseudo table?

    I am trying to create a trigger on a table but when I check the syntax it
    tells me that "The column prefix 'inserted' does not match with a table name or alias used in this query"

    Code:
    CREATE TRIGGER trg_Structural_GenerateBarcode ON [dbo].[tbStructuralComponentSchedule] 
    AFTER INSERT 
    AS
    DECLARE @iCount int, @cBarcode char (25), @cCode char(4)
    DECLARE @cProject char(7), @cComponent char(10), @iEntryID int
    
    SELECT @cProject = inserted.fkProjectNumber, @cComponent = inserted.fkComponentID, @iEntryID = inserted.EntryID
    
    .......
    GO
    How do I use the inserted pseudo table?

    Mike B

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Maybe a "FROM inserted" would help?

    Just FYI, a trigger fires for each SQL statement, not for each row. Be careful about assuming that only one row will be returned.

    -PatP

  3. #3
    Join Date
    Feb 2004
    Posts
    134
    Quote Originally Posted by Pat Phelan
    Maybe a "FROM inserted" would help?

    Just FYI, a trigger fires for each SQL statement, not for each row. Be careful about assuming that only one row will be returned.

    -PatP
    Thanks for the tip. I did not know that. I don't believe it will affect me, but definately good too know

    Mike B

Posting Permissions

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