Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2006

    Unanswered: local variable assignment in CREATE TRIGGER

    Hi Guys,

    i'm batttling with the below Trigger creation

    __________________________________________________ _
    CREATE TRIGGER dbo.Fochini_Insert ON dbo.FochiniTable AFTER INSERT AS
    DECLARE @v_object_key VARCHAR(80)
    DECLARE @v_object_name VARCHAR(40)
    DECLARE @v_object_verb VARCHAR(40)
    DECLARE @v_datetime DATETIME

    SELECT ins.Cust_Id INTO @v_object_key FROM inserted ins <--- my problem area!!
    SET @v_object_name = 'FochiniTable'
    SET @v_object_verb = 'Create'
    SET @v_datetime = GETDATE()

    IF ( USER <> 'webuser' )
    INSERT INTO dbo.xworlds_events (connector_id, object_key, object_name, object_verb, event_priority, event_time, event_status, event_comment)
    VALUES ('Fochini', @v_object_key, @v_object_name, @v_object_verb, '1', @v_datetime,'0', 'Triggered by Customer CREATE')


    i'm trying to get the INSERTED variable from table FochiniTable on colomn Cust_Id

    and the statement: SELECT ins.Cust_Id INTO @v_object_key FROM inserted ins - is failing [still a newbie on mssql server 2000]

    any help will be appreciated

  2. #2
    Join Date
    Feb 2006
    solved by modifying the errored line with

    SELECT @v_object_key = ins.Cust_Id FROM inserted ins

    thanx any wayz

Posting Permissions

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