IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_save_doc_text]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_save_doc_text]
GO
CREATE proc [dbo].[mps_save_doc_text]
@docid int,
@content text,
@abs nvarchar(200),
@search nvarchar(max)
as
begin
    set nocount on
    declare @count int 
--插入文档正文表或更新
select @count=count(docd_docid) from mps_document_text where docd_docid = @docid
if @count>0
begin
    update mps_document_text set docd_text = @content where docd_docid =@docid
end
else
begin
    insert into mps_document_text(docd_docid,docd_text)
values(@docid,@content)
end
--更新文档基础信息表
declare @archive int;
select @archive = doc_archive from mps_document where doc_id = @docid

update mps_document set doc_abstract=@abs,doc_search=@search where doc_id = @docid
set nocount off
end