I was given this script by a co-worker but when I run it it only does one update then stops, when I close out of management studeio I am told there are uncommented transactions. If I comment out the SELECT code everything works fine. I have been looking it over for about 20 minutes not I do not see anything wrong. Can anyone point out what I am missing?
BEGIN TRY
BEGIN TRANSACTION
USE DOD;
---------------------------------------------------------------------------
--They can't reconcile the order because the IsReconciled flag is Y.
---------------------------------------------------------------------------
DECLARE @MnfstID Int;
SELECT @MnfstID = m.MnfstID
FROM dbo.Manifest AS m WITH (NOLOCK)
WHERE m.mnfstid = (
SELECT mnfstid
FROM OrderManifest AS om WITH (NOLOCK)
WHERE om.Ordrnmbr = 503326
);
SELECT @MnfstID;
RETURN;
---------------------------------------------------------------------------
--Once you have the mnfstid value you can update the IsReconciled flag to N
---------------------------------------------------------------------------
UPDATE m
SET m.IsReconciled = 'N'
--Select m.*
FROM dbo.Manifest AS m
WHERE m.MnfstID = @MnfstID;
--COMMIT
ROLLBACK
END TRY
BEGIN CATCH
ROLLBACK
END CATCH
--
If I get used to envying others...
Those things about my self I pride will slowly fade away.
-Stellvia