我在SQL Server 2008中有一個存儲過程,需要刪除幾行數據。但是當我運行它時,它會返回一個失敗並且值爲-6。SQL Server存儲過程返回'失敗'
ALTER procedure [dbo].[p_CaseFiles_Exhibits_DeleteExhibits]
@ExhibitID int
, @Message nvarchar(50) output
as
declare @FileID int
set @FileID = (select FileID from CaseFileExhibits where ExhibitID = @ExhibitID)
begin transaction
begin try
delete from CaseFileExhibitMovementTracking where ExhibitID = @ExhibitID
delete from CaseFileExhibitAttachments where CaseFileExhibitID = @ExhibitID
delete from CaseFileExhibits where ExhibitID = @ExhibitID
delete from CaseFileExhibitPropertyLink where ExhibitID = @ExhibitID
update CaseFileQuickStats set ExhibitCount = ExhibitCount -1 where CaseFileID = @FileID
commit transaction
end try
begin catch
set @Message='Fail'
rollback transaction
end catch
我似乎無法找到問題所在。
對不起。更改了它 – user1084319
您是否嘗試單獨運行每個查詢的存儲過程以查看哪個查詢可能失敗?或者甚至在存儲過程之外單獨運行每一個? – Taryn
您應該使用** TAGS **這種「meta」信息 - 我現在爲您更新了 –