SELECT 表值函数1(n1.news_id,s1.shuxing_1) as func_val
FROM [新闻表] n1 FULL JOIN [属性表] s1 ON 1=1
UNION ALL
SELECT 表值函数2(n2.news_id,s2.) as func_val
FROM [新闻表] n2 FULL JOIN [另一个属性表] s2 ON 1=1;
ECLARE cussor1 CURSOR FOR
select news_id from 新闻表 into @newsid
OPEN cussor1
FETCH NEXT FROM cussor1 INTO @newsid
WHILE @@FETCH_STATUS = 0
BEGIN
ECLARE cussor2 CURSOR FOR
select shuxing_1 from 属性表 into @shunxing
OPEN cussor2
FETCH NEXT FROM cussor2 INTO @shunxing
WHILE @@FETCH_STATUS = 0
begin
select * from 表值函数1(@newsid,@shunxing)
FETCH NEXT FROM cussor2 INTO @shunxing
end
CLOSE cussor2
DEALLOCATE cussor2
ECLARE cussor3 CURSOR FOR
select shuxing_2 from 另一个属性表 into @shunxing2
OPEN cussor3
FETCH NEXT FROM cussor3 INTO @shunxing
WHILE @@FETCH_STATUS = 0
begin
select * from 表值函数2(@newsid,@shunxing2)
FETCH NEXT FROM cussor2 INTO @shunxing2
end
CLOSE cussor3
DEALLOCATE cussor3