 
if exists (select * from dbo.sysobjects where id = object_id(N'[BoardDeleteA]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [BoardDeleteA]
GO

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
/***********************************************
***功能描述：---根据主键删除Board表的记录。
***传入传出参数：

***作者：朱祁林
***建立时间:2009-2-15
***更改时间：
***更改人：
***更改原因：
 ****************************************************/
CREATE PROCEDURE BoardDeleteA
	(
	@BoardID INT,
	@ReturnCode int OUTPUT
	)
AS
 set @ReturnCode=0;
BEGIN 
IF  exists (SELECT  1 FROM [dbo].[Board] WHERE [dbo].[Board].ParentID =@BoardID )
set @ReturnCode=20004;
IF  exists (SELECT  1 FROM [dbo].[SubjectMST] WHERE [dbo].[SubjectMST].BoardID =@BoardID )
set @ReturnCode=20005;

begin
IF @ReturnCode=0
begin 
DELETE FROM [dbo].[Board]
WHERE
	[BoardID]=@BoardID
	end 
	END
end
	
GO

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO
