http://topic.csdn.net/u/20091006/15/4e5624a8-c975-4442-b470-7f0262e81268.html
µ±µÚ3²½Ò²°üº¬µÚÒ»²½µÄ°ë³ÉÆ·£¬ÄÇô½á¹ûÓеãÎÊÌâ¡££¨ÏȰÑ--select 15,4,'H-HP-WH2980',1 union all£©×¢ÊÍ£¬³öÀ´µÄÊý¾ÝûÎÊÌ⣬²»×¢Ê͵Äʱºò¾Í²»¶Ô£¬Âé·³¿´Ï¡£
Select * into SP_ProductP from (select 11 as ProductP_ID ,19 as ProductP_PID ,1 as ProductP_Order union all select 12,19,2 union all select 15,19,3 ) as aa
Select * into SP_ProductPItem from (
select 11 as ProductPI_PID ,2 as ProductPI_Type ,'BD0001' as ProductPI_MHNO,11 as ProductPI_UQty union all
select 11,2,'BD0003',20 union all
select 11,2,'BD0022',5 union all
select 12,2,'BD0005',3 union all
select 12,4,'H-HP-WH2980',2 union all
select 12,2,'BD0001',2 union all
--select 15,4,'H-HP-WH2980',1 union all
select 15,4,'H2-HP-WH2980',3 union all
select 15,2,'BD0008',5
) as bb
CREATE FUNCTION f_Bom(
@PID int
)RETURNS @t TABLE(ProductPI_PID int,ProductPI_Type int,ProductPI_MHNO varchar(20),ProductPI_UQty int,ProductP_Order int,Level int)
AS
BEGIN
DECLARE @Level int,@sRow int
SET @Level=1
Select @sRow =max(ProductP_Order) from SP_ProductP Where ProductP_PID =@PID
INSERT @t
select sub.ProductPI_PID
ÎÒÓжà¸ö±íA B C ½á¹¹ÊÇÒ»ÑùµÄ£¬¶¼ÓÐ2¸ö×Ö¶ÎnameºÍcontent,ÎÒÒªËÑË÷ËùÒÔ±íËùÓÐ×Ö¶ÎÖаüº¬¡°Öйú¡±µÄÄÚÈÝ Õâ¸öSQLÓï¾äÔõôд
ÈçºÎ½«¶à¸ö±íµÄ²éѯ½á¹ûÁ¬³ÉÒ»¸ö±í Õâ¸öSQLÓï¾äÔõôд ±íµÄ½á¹¹ÊÇÒ»ÑùµÄ
ÀýÈç£ ......