SQL Server Performance

How to pass parameters for trigger?

Discussion in 'General Developer Questions' started by lalitha_karani, Feb 2, 2007.

  1. lalitha_karani New Member

    I want to pass parameters for triggers. Is this possible? if so please give me code how to pass parameters for trigger/

    Thanking You,
  2. madhuottapalam New Member

    no it is not possible to pass parameter to a trigger. pse post your requirement, there may be other ways to address your problem

  3. rao New Member


    it is not possible to pass parameters to the trigger.
  4. Adriaan New Member

    In triggers, you can get to the data in the affected rows, as it was before and after the event, through the deleted and inserted conceptual tables. One restriction: you cannot refer to columns of TEXT, NTEXT and other 'large' types.

    One example is a way to set a 'default for an update', like to automatically change the LastUpdated column on an inserted or updated row:

    CREATE TRIGGER MyTrigger ON dbo.MyTable

    UPDATE t
    SET t.LastUpdated = GETDATE()
    FROM dbo.MyTable t
    INNER JOIN inserted i ON t.keycolumn = i.keycolumn


    For inserts, you only have the inserted snapshot.
    For updates, you have both the inserted and deleted snapshots.
    For deletes, you only have the deleted snapshot.

    If the update or delete is caused by a cascading relationship from a parent table, then the corresponding snapshot is empty.
  5. FrankKalis Moderator

    Care to explain what you are trying to achieve?
    Probably there is another way.

    Frank Kalis
    Microsoft SQL Server MVP
  6. lalitha_karani New Member

    Thank you to all for u r time, i faced this question in interview. so just i want to know the answer.

    Thanking you,
  7. khtan New Member

    Sounds like a trick question [<img src='/community/emoticons/emotion-2.gif' alt=':D' />]<br /><br /><hr noshade size="1"><br /><font color="blue"><font size="1"><i>KH</i></font id="size1"></font id="blue">
  8. FrankKalis Moderator

Share This Page