日期:2014-05-18 浏览次数:21115 次
ALTER FUNCTION [dbo].[f_PCB_GetChildContractID] ( @ContractID INT ) RETURNS @Temp TABLE ( ContractID INT ) AS BEGIN DECLARE @ParentID INT SELECT @ParentID = ParentID FROM dbo.BS_Contract WHERE ID = @ContractID IF(@ParentID = 0 OR @ParentID IS NULL) BEGIN --父合同 INSERT INTO @Temp SELECT ContractID FROM v_PCB_Planning WHERE Status IN ('4', '5', '6', '7', '8') AND ParentID = @ContractID END ELSE BEGIN --其本身就是自合同 INSERT INTO @Temp SELECT @ContractID END --返回 RETURN END GO