单级正展:select * from BOM表 where parentitem = 'B-WG-XJ-QG-12'
多级正展:
;with cte As
(
select * from BOM表 where parentitem = 'CP-WG-JSG-0210'
union all
select a.* from BOM表 a
join cte on a.parentitem = cte.childitem
)
select * from cte
至于原材料正展,不知道childtype 有没有表示出原材料。假设 childtype 等于 00为原材料的话:
;with cte As
(
select * from BOM表 where parentitem = 'CP-WG-JSG-0210'
union all
select a.* from BOM表 a
join cte on a.parentitem = cte.childitem
)
select * from cte where childtype = '00'
可以用fill 方法把数据直接填充到 表里面去
tables("窗口1_table1").Fill("SQL语句","外部数据源",true)