Sql Server触发器不执行多行

时间:2011-11-02 15:55:03

标签: sql sql-server tsql triggers

我试图通过从其他表中选择行来向表中插入行。该表具有触发器,用于处理使用游标插入的所有行。但是当我执行insert时,它只处理1行,同时插入了多行。这是我现在的代码。我错过了什么吗?

    INSERT INTO <table>(<columns>) VALUES
    SELECT <columns>
    FROM <table> WHERE <condition> ORDER BY <column>


    ALTER TRIGGER <trgName>
    ON <table>
    AFTER INSERT
    AS
    BEGIN

   declare cur_inserted cursor for select <col1>,<col2> from inserted
   open cur_inserted

   fetch next from cur_inserted into @var1,@var2
   while @@fetch_status = 0
   begin

       ---- LOGIC to process each row here

   fetch next from cur_inserted into @schedule_nbr,@stn_cd
   end

   close cur_inserted
    deallocate cur_inserted
 END

谢谢,

Jignesh

0 个答案:

没有答案