我使用此查詢在表tblWorkOrders中插入一行。 但是@@ ROWCOUNT給出了0事件,但是表中插入了一行。 可能是什麼原因?如何更改查詢以提供正確的@@ ROWCOUNT?@@ rowcount插入後沒有給出正確的值
INSERT INTO tblWorkOrders
( WO_Type , WO_Yard , WO_Operation , WO_Source , WO_SourceID , WO_SourceXLocation , WO_SourceYLocation ,
WO_Destination , WO_DestinationID , WO_DestinationXLoc, WO_DestinationYLoc , WO_Crane , WO_Priority ,
WO_ScheduledAt , WO_CoilNo , WO_ExecutionStart , WO_ExecutionEnd , WO_ExecutedBy , WO_Remarks,WO_RequestRefID)
(SELECT OM_WOType,OM_Yard,OM_OperationsID,'Saddle' ,STARTINGPOINT.NAME,STARTINGPOINT.XAxis,STARTINGPOINT.YAxis,
'Saddle',ENDINGPOINT.NAME,ENDINGPOINT.XAxis,ENDINGPOINT.YAxis,OM_AssignedCrane,NULL,
NULL,@COILNO,NULL,NULL,NULL,NULL,NULL
FROM
tblOperationsMaster OPM
INNER JOIN
(SELECT SP_OperatingPointID AS [NAME],SP_XLocation AS [XAxis],SP_YLocation AS [YAxis] FROM tblStandardPoints
UNION ALL
SELECT SM_SaddleID AS [NAME],SM_XCoordinate AS [XAxis],SM_YCoordinate AS [YAxis] FROM tblSaddleMaster) STARTINGPOINT
ON STARTINGPOINT.NAME = @SOURCEIDFROMCALLINGFN
INNER JOIN
(SELECT SP_OperatingPointID AS [NAME],SP_XLocation AS [XAxis],SP_YLocation AS [YAxis] FROM tblStandardPoints
UNION ALL
SELECT SM_SaddleID AS [NAME],SM_XCoordinate AS [XAxis],SM_YCoordinate AS [YAxis] FROM tblSaddleMaster) ENDINGPOINT
ON ENDINGPOINT.NAME = @DESTINATIONIDFROMCALLINGFN
WHERE OPM.OM_OperationsID = @OPERATIONID)
SET @ROWSINSERTED = @@ROWCOUNT;