Azurden
asked on
MS SQL Trigger
Hey All!
Ok, new to MS SQL triggers... SO, I need to try and do the following...
1: 2 tables SYS_USER, SERV_REQUEST, and SERV_NOTE
2: When a user is deleted from SYS_USER I need all refrences in SERV_REQUEST, and SERV_NOTE to be deleted as well.
3: I want the trigger to be on the SYS_USER table.
Here is the SQL for the tables and the joins...
SELECT
user1229049.SYS_USER.ID_US ER,
user1229049.SYS_USER.ID_DI STRICT,
user1229049.SYS_USER.ID_BU ILDING,
user1229049.SYS_USER.[USER _NAME],
user1229049.SYS_USER.USER_ PASSWORD,
user1229049.SYS_USER.FIRST _NAME,
user1229049.SYS_USER.LAST_ NAME,
user1229049.SYS_USER.EMAIL ,
user1229049.SYS_USER.RIGHT S,
user1229049.SERV_REQUEST.I D_REQUEST,
user1229049.SERV_REQUEST.I D_DISTRICT ,
user1229049.SERV_REQUEST.I D_BUILDING ,
user1229049.SERV_REQUEST.I D_ADMIN,
user1229049.SERV_REQUEST.I D_TECHNICI AN,
user1229049.SERV_REQUEST.I D_USER,
user1229049.SERV_REQUEST.I D_PRIORITY ,
user1229049.SERV_REQUEST.I D_SUB_PRIO RITY,
user1229049.SERV_REQUEST.I D_ROOM,
user1229049.SERV_REQUEST.I D_SERVICE_ TYPE,
user1229049.SERV_REQUEST.I D_SUB_SERV ICE_TYPE,
user1229049.SERV_REQUEST.I D_START_ST ATUS,
user1229049.SERV_REQUEST.I D_SERVICE_ STATUS,
user1229049.SERV_REQUEST.I D_MODIFIED _LAST_BY,
user1229049.SERV_REQUEST.I NVENTORY_T AG,
user1229049.SERV_REQUEST.R EQUEST_POS TED_DATE,
user1229049.SERV_REQUEST.R EQUEST_REQ UESTED_DAT E,
user1229049.SERV_REQUEST.R EQUEST_OPE N_DATE,
user1229049.SERV_REQUEST.R EQUEST_MOD IFIED_DATE ,
user1229049.SERV_REQUEST.R EQUEST_CLO SED_DATE,
user1229049.SERV_REQUEST.R EQUEST_SER VICE_TIME_ TOTAL,
user1229049.SERV_REQUEST.I SSUE_DESCR IPTION,
user1229049.SERV_NOTE.ID_N OTE,
user1229049.SERV_NOTE.ID_S ERV_REQUES T,
user1229049.SERV_NOTE.ID_U SER_TYPE,
user1229049.SERV_NOTE.POST ED_DATE,
user1229049.SERV_NOTE.NOTE
FROM
user1229049.SYS_USER
INNER JOIN user1229049.SERV_REQUEST ON (user1229049.SYS_USER.ID_U SER = user1229049.SERV_REQUEST.I D_USER)
INNER JOIN user1229049.SERV_NOTE ON (user1229049.SERV_REQUEST. ID_REQUEST = user1229049.SERV_NOTE.ID_S ERV_REQUES T)
Here is the start of the trigger...
CREATE TRIGGER [SYS_USER (user1229049)].[SYS_USER_t rd] ON [SYS_USER (user1229049)].[]
FOR DELETE
AS
BEGIN
/* Trigger body */
END
GO
Any help would be great!
Az
Ok, new to MS SQL triggers... SO, I need to try and do the following...
1: 2 tables SYS_USER, SERV_REQUEST, and SERV_NOTE
2: When a user is deleted from SYS_USER I need all refrences in SERV_REQUEST, and SERV_NOTE to be deleted as well.
3: I want the trigger to be on the SYS_USER table.
Here is the SQL for the tables and the joins...
SELECT
user1229049.SYS_USER.ID_US
user1229049.SYS_USER.ID_DI
user1229049.SYS_USER.ID_BU
user1229049.SYS_USER.[USER
user1229049.SYS_USER.USER_
user1229049.SYS_USER.FIRST
user1229049.SYS_USER.LAST_
user1229049.SYS_USER.EMAIL
user1229049.SYS_USER.RIGHT
user1229049.SERV_REQUEST.I
user1229049.SERV_REQUEST.I
user1229049.SERV_REQUEST.I
user1229049.SERV_REQUEST.I
user1229049.SERV_REQUEST.I
user1229049.SERV_REQUEST.I
user1229049.SERV_REQUEST.I
user1229049.SERV_REQUEST.I
user1229049.SERV_REQUEST.I
user1229049.SERV_REQUEST.I
user1229049.SERV_REQUEST.I
user1229049.SERV_REQUEST.I
user1229049.SERV_REQUEST.I
user1229049.SERV_REQUEST.I
user1229049.SERV_REQUEST.I
user1229049.SERV_REQUEST.R
user1229049.SERV_REQUEST.R
user1229049.SERV_REQUEST.R
user1229049.SERV_REQUEST.R
user1229049.SERV_REQUEST.R
user1229049.SERV_REQUEST.R
user1229049.SERV_REQUEST.I
user1229049.SERV_NOTE.ID_N
user1229049.SERV_NOTE.ID_S
user1229049.SERV_NOTE.ID_U
user1229049.SERV_NOTE.POST
user1229049.SERV_NOTE.NOTE
FROM
user1229049.SYS_USER
INNER JOIN user1229049.SERV_REQUEST ON (user1229049.SYS_USER.ID_U
INNER JOIN user1229049.SERV_NOTE ON (user1229049.SERV_REQUEST.
Here is the start of the trigger...
CREATE TRIGGER [SYS_USER (user1229049)].[SYS_USER_t
FOR DELETE
AS
BEGIN
/* Trigger body */
END
GO
Any help would be great!
Az
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.