存储过程最后返回的结果集如何跟函数返回的变量表连接
declare @sql varchar(500)
set @sql= 'select a.*,b.VTitle from VideoComment a inner join VideoInfo b on a.VID=b.VID where ' + @TimeFilter + 'and '+@VIDFilter
exec(@sql)--最后返回的结果集
dbo.Fun_GetChannelListByParID(ChannelID)--这个函数返回一个变量表
如何把这两个结果集连接起来
先谢过了
------解决方案--------------------declare @sql varchar(500)
set @sql= 'select * from dbo.Fun_GetChannelListByParID(ChannelID) union all '
set @sql= @sql + 'select a.*,b.VTitle from VideoComment a inner join VideoInfo b on a.VID=b.VID where ' + @TimeFilter + 'and '+@VIDFilter
exec(@sql)
------解决方案--------------------1.把存储过程的结果存成临时表#
2.连接
select * from dbo.Fun_GetChannelListByParID(ChannelID) a Inner Join # b on a.nid=b.ChannelID