CREATE PROCEDURE [dbo].[TR_PROC_UpdateRelMgrByHrID]
(
@REF_DIV_ID Int,
@STAFFIDS varchar(500)
)
AS
BEGIN
BEGIN TRAN
-- DECLARE @STAFFIDS varchar(8000)
-- SET @STAFFIDS = '2,19,14'
DECLARE @temptable TABLE (items int)
INSERT INTO @temptable
VALUES(@REF_DIV_ID)
DELETE FROM Tbl_RelationshipMgr
WHERE IntHRID = @REF_DIV_ID
INSERT INTO Tbl_RelationshipMgr(IntStaffID,IntHRID)
SELECT * from dbo.Split(@STAFFIDS, ','), @temptable
COMMIT
END
答案 0 :(得分:1)
在MySQL中你的sp可以写成: -
DELIMITER $$
CREATE PROCEDURE TR_PROC_UpdateRelMgrByHrID
(
REF_DIV_ID INT(11)
)
BEGIN
START TRANSACTION;
INSERT INTO items VALUES (REF_DIV_ID);
DELETE FROM Tbl_RelationshipMgr WHERE IntHRID = REF_DIV_ID;
INSERT INTO Tbl_RelationshipMgr(`IntStaffID`,`IntHRID`) SELECT * from items ;
COMMIT;
END$$
DELIMITER ;
您可能希望根据需要更改查询。