Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
jch04
Starting Member
9 Posts |
Posted - 2009-01-15 : 03:46:42
|
Hello to all community,I need to improve the performance of the following trigger:CREATE trigger [ATTENDANCE_INSUPDDEL] on [dbo].[ATTENDANCE] for update,insert,deleteasdeclare @r intdeclare cur cursor for select distinct registration from inserted union select distinct registration from deletedopen curfetch next from cur into @rwhile @@fetch_status=0 begin exec sync_attendance @r fetch next from cur into @r endclose curdeallocate curAny ideas to rewrite the trigger without cursors?? |
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2009-01-15 : 04:00:04
|
we would need to know/see what sync_attendance does |
|
|
jch04
Starting Member
9 Posts |
Posted - 2009-01-15 : 04:42:49
|
Yes you are right, below is the code of sync_attendance:CREATE procedure [dbo].[sync_attendance] @registration intasdeclare @student intdeclare @semester intset @student=(select distinct student from registration where code=@registration)set @semester=(select distinct semester from registration where code=@registration)delete from _totalgrade where student=@student and semester=@semesterinsert into _totalgrade select distinct * from fn_totalgrade(@student, @semester)delete from _stud_progress where student=@student and psem>=@semesterinsert into _stud_progress select distinct * from stud_progress where psem>=@semester and student=@student |
|
|
|
|
|