日期:2014-05-17 浏览次数:20660 次
alter Proc GetAnswer
@Count varchar(5) =false,
@Time Varchar(5) =false,
@Support varchar(5)=false
as
declare @sql nvarchar(max)
set @sql='select AA.ID,AA.TopicID,AA.Content,AA.Posttime,
U.UserName,U.Support,U.Avatar
from Ask_Answer as AA
join Jst_User.dbo.User_Info as U on U.Uid=AA.UserID'
if(@Count <> 'false')
begin
set @sql='select Top '+@Count+' AA.ID,AA.TopicID,AA.Content,AA.Posttime,
U.UserName,U.Support,U.Avatar
from Ask_Answer as AA
join Jst_User.dbo.User_Info as U on U.Uid=AA.UserID'
if(@Time = 'True')
begin
set @sql='select Top '+@Count+' AA.ID,AA.TopicID,AA.Content,AA.Posttime,
U.UserName,U.Support,U.Avatar
from Ask_Answer as AA
join Jst_User.dbo.User_Info as U on U.Uid=AA.UserID order by AA.Posttime desc'
end
if(@Support = 'True')
begin
set @sql='select Top '+@Count+' AA.ID,AA.TopicID,AA.Content,AA.Posttime,
U.UserName,U.Support,U.Avatar
from Ask_Answer as AA
join Jst_User.dbo.User_Info as U on U.Uid=AA.UserID order by U.Support desc'
end
end
exec sp_executesql @sql