-
need help with trigger/cursor
Hi,
When I copy data form MyTable1 into MyTable2, values of OrderNo column has to be equal AutoID( identity column) minus 1.
The below trigger does that.
But it works only with One record.
When I copy more then 1 record it stops working.
Can someone help me how to make it work on multiple insert.
Thanks,
rudi
CREATE TRIGGER mytable_insert2 ON MyTable2 FOR INSERT
AS
declare @ID int
declare @Counter char(6)
select @ID = @@Identity from inserted
select @Counter=@ID
update MyTable2
set OrderNo = @Counter-1
where AutoID = @ID
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|