Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003
    Posts
    2

    Arrow Unanswered: how to pass parameters to a trigger?

    I try to insert a record from TableA and TableB into TableC but I need to pass some parameters from my application to the TableA and TableB before insert in TableC, otherwise the values are variables; my question is, How can I pass these parameters to a trigger ? or What do you recommend me to do?

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    You sure you mean TRIGGER?

    Can you post what you've got now?
    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.

  3. #3
    Join Date
    Dec 2002
    Posts
    1,245

    Re: how to pass parameters to a trigger?

    I'm thinking that what you really want is a stored Procedure. Something perhaps like:

    Code:
    CREATE PROC spInsertRecord
    
        @RecordID as Int
    
    AS
    
    DECLARE @ColumnA varchar(20), ColumnB varchar(20)
    
    SELECT @ColumnA =  ColumnA
    FROM 
      TableA
    WHERE
      ID = @RecordID
    
    SELECT @ColumnB = ColumnB
    FROM
      TableB
    WHERE
      ID = @RecordID
    
    INSERT INTO TableC (ColumnA, ColumnB, ID)
    VALUES (@ColumnA, @ColumnB, @RecordID)
    
    GO
    
    
    Exec spInsertRecord @RecordID = 10
    Originally posted by cserrato
    I try to insert a record from TableA and TableB into TableC but I need to pass some parameters from my application to the TableA and TableB before insert in TableC, otherwise the values are variables; my question is, How can I pass these parameters to a trigger ? or What do you recommend me to do?

Posting Permissions

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