院校搜索存储过程

ALTER PROCEDURE [dbo].[Sp_SearchSchool]
 -- Add the parameters for the stored procedure here
@countryid int=0,
@resumeid int=0,
@paytype int=0
AS
declare @sql nvarchar(4000)
declare @cons varchar(200)
set @cons=''
if(@resumeid>0)
begin
set @cons=@cons+' and resumeid='+cast(@resumeid as varchar(20))
end
if(@paytype>0)
begin
set @cons=@cons+' and paytype='+cast(@paytype as varchar(20))
end
set @sql='select a.*,b.* from dbo.T_UniversityInfo a inner join  (select count(id) as countnum,unid from T_SchoolSpec where 1=1'+@cons+' group by unid) b

on a.id=b.unid'

exec(@sql)

posted @ 2008-10-13 00:00  Jason.Bird  阅读(204)  评论(0编辑  收藏  举报