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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-02-26 : 09:11:48
|
| micheal writes "The following is a stored procedure and a trigger that i am using in a college project, i think syntactically that the trigger is correct. but it just aint been called when the spDeleteUsers stored procedure is called.Please note: all tables that are deleted from are only tied to tblUsers so i don't think that the order of deletion mattersas they have no fields that are Foreign keys in other tables:anyways i'm deleting them in the order that the relationships are created also no other triggers exist therefore not a recursive trigger and also the trigger has been enabledANY help would be much appreciatedcheersmichealCREATE TRIGGER trCascadeDeleteUsersON tblUsersFOR DELETEASDECLARE @UserId intSELECT @UserId = User_IdFROM DeletedDELETE from tblTimesheetsWHERE tblTimesheets.User_Id = @UserIdDELETE from tblTimesheetsItemWHERE tblTimesheetsItems.User_Id = @UserIdDELETE from tblUserAssignedTasksWHERE tblUserAssignedTasks.User_Id = @UserIdDELETE from tblGroupsWHERE tblGroups.User_Id = @UserIdCREATE PROCEDURE spDeleteUsers@UserId intAS DELETEFROM tblUsersWHERE UserId = @UserIdCheers Micheal" |
|
|
Nazim
A custom title
1408 Posts |
Posted - 2002-02-26 : 10:20:16
|
| Have a look at the profiler for the value of @UserID.i would suggest you to change your delete statements on this lines. as your existing assingment of user_id to @user_id might work only for a single record deletion( Am not sure about it you should check it).DELETE from tblTimesheetsWHERE tblTimesheets.User_Id = @UserIdtoDELETE from tblTimesheetsfrom tblTimeSheets t inner join Deleted don t.user_id=d.userid-------------------------------------------------------------- |
 |
|
|
|
|
|