[dbo].[MssWebDeleteDocument]
CREATE PROCEDURE [dbo].[MssWebDeleteDocument]
@inOrderId int = 0,
@inDocumentId int,
@inDocumentDeletionReasonId int,
@inClientSysUserId int
AS
begin
set nocount on
declare @thePreviousDocImageId int = (
select top 1 MssDocumentImageFID
from MssDocument
where
OrderFID = @inOrderId and
MssDocumentID = @inDocumentId )
if @thePreviousDocImageId is null
begin
return;
end
update MssDocument set
DocumentDeletionReasonFID = @inDocumentDeletionReasonId,
DeletedOn = getdate(),
DeletedBy = @inClientSysUserId,
MSSDocumentImageFID = null,
ContentUrl = null
where MssDocument.MssDocumentID = @inDocumentId
delete from MssDocumentImage where MssDocumentImageId = @thePreviousDocImageId
end
GO
GRANT EXECUTE ON [dbo].[MssWebDeleteDocument] TO [MssExec]
GO