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'+@VIDFilterexec(@sql)--最后返回的结果集dbo.Fun_GetChannelListByParID(ChannelID)--这个函数返回一个变量表如何把这两个结果集连接起来先谢过了

解决方案 »

  1.   

    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'+@VIDFilterexec(@sql)
      

  2.   

    可能不是这样,这是想通过dbo.Fun_GetChannelListByParID(ChannelID) 和 exec(@sql) 的
    ChannelID来连按
    如:
    select * from dbo.Fun_GetChannelListByParID(ChannelID) as a inner join exec(@sql) as b on a.nid=b.ChannelID但是这样好像语法不通
      

  3.   

    1.把存储过程的结果存成临时表#
    2.连接
    select * from dbo.Fun_GetChannelListByParID(ChannelID) a Inner Join # b on a.nid=b.ChannelID