[转]分页存储过程set ANSI_NULLS ON
[转]分页存储过程
set QUOTED_IDENTIFIER ON
[转]分页存储过程
go
[转]分页存储过程
[转]分页存储过程 
[转]分页存储过程
[转]分页存储过程
CREATE PROC [dbo].[user_index] 
[转]分页存储过程(
[转]分页存储过程
@PageIndex int,
[转]分页存储过程
@PageSize int,
[转]分页存储过程
@education_id nvarchar(200)=null,
[转]分页存储过程
@city_id nvarchar(200)=null,
[转]分页存储过程
@language_id nvarchar(200)=null,
[转]分页存储过程
@key nvarchar(200)=null,
[转]分页存储过程
@sex nvarchar(200)=null,
[转]分页存储过程
@height1 nvarchar(200)=null,
[转]分页存储过程
@height2 nvarchar(200)=null,
[转]分页存储过程
@age1 nvarchar(200)=null,
[转]分页存储过程
@age2 nvarchar(200)=null
[转]分页存储过程)              
[转]分页存储过程
as
[转]分页存储过程
[转]分页存储过程
create table  #table 
[转]分页存储过程(id 
int,name nvarchar(100),education nvarchar(100),city nvarchar(100),sex nvarchar(100),age nvarchar(100),height nvarchar(100),
[转]分页存储过程uid 
uniqueidentifier)
[转]分页存储过程
[转]分页存储过程
declare @Where nvarchar(4000)        
[转]分页存储过程
set @Where=''      
[转]分页存储过程
IF @education_id IS NOT null   AND  @education_id <>''      
[转]分页存储过程
BEGIN        
[转]分页存储过程
select @Where=@Where + ' AND general_education.general_education_id >= '+@education_id+''      
[转]分页存储过程
END    
[转]分页存储过程
[转]分页存储过程
IF @city_id IS NOT null   AND  @city_id <>''      
[转]分页存储过程
BEGIN        
[转]分页存储过程
select @Where=@Where + ' AND city.place_id = '+@city_id+''      
[转]分页存储过程
END     
[转]分页存储过程
[转]分页存储过程
IF @language_id IS NOT null   AND  @language_id <>''      
[转]分页存储过程
BEGIN        
[转]分页存储过程
select @Where=@Where + ' AND lang.language_id = '+@language_id+''      
[转]分页存储过程
END 
[转]分页存储过程 
[转]分页存储过程
IF @sex IS NOT null   AND  @sex <>''      
[转]分页存储过程
BEGIN 
[转]分页存储过程
set @Where=@Where+' AND sex = '''+@sex+''''        
[转]分页存储过程
END     
[转]分页存储过程
[转]分页存储过程
IF @height1 IS NOT null   AND  @height1 <>'' and @height2 IS NOT null   AND  @height2 <>''     
[转]分页存储过程
BEGIN        
[转]分页存储过程
select @Where=@Where + ' and (height between '+@height1+' and '+@height2+')'      
[转]分页存储过程
END   
[转]分页存储过程
[转]分页存储过程
IF @age1 IS NOT null   AND  @age1 <>'' and @age2 IS NOT null   AND  @age2 <>''     
[转]分页存储过程
BEGIN        
[转]分页存储过程
select @Where=@Where + ' and (datediff(year,birthday,getdate()) between '+@age1+' and '+@age2+')'      
[转]分页存储过程
END      
[转]分页存储过程        
[转]分页存储过程
IF @key IS NOT  null   AND @key <>''      
[转]分页存储过程
BEGIN        
[转]分页存储过程
set @Where=@Where + ' and user_work_exp.work_exp_description LIKE ''%'+@key+'%'''        
[转]分页存储过程
END 
[转]分页存储过程
print @where         
[转]分页存储过程       
[转]分页存储过程
declare @sql nvarchar(4000)   
[转]分页存储过程
set @sql='insert into #table select distinct user_profile_id,name,general_education.generl_education_desc,city.reg_name,sex,
[转]分页存储过程datediff(year,birthday,getdate())as age,height,user_profile.uid 
[转]分页存储过程from user_profile left join general_education on user_profile.general_education_id=general_education.general_education_id 
[转]分页存储过程left join user_work_exp on user_work_exp.uid=user_profile.uid left join 
[转]分页存储过程(select location_id,location.place_id,reg_name from location left join location_place on location.place_id=location_place.place_id)as city
[转]分页存储过程on city.location_id=user_profile.location_id left join 
[转]分页存储过程(select user_language_skill.language_id,user_language_skill.uid,user_language_type.language_name from 
[转]分页存储过程user_language_skill left join user_language_type on user_language_skill.language_id=user_language_type.language_id) as lang
[转]分页存储过程on lang.uid=user_profile.uid where 1=1 
'+ @Where
[转]分页存储过程
print @sql
[转]分页存储过程
exec(@sql)
[转]分页存储过程
[转]分页存储过程
[转]分页存储过程
if(@PageIndex=1)
[转]分页存储过程
begin
[转]分页存储过程
select top (@PageSize* from #table
[转]分页存储过程
end
[转]分页存储过程
else
[转]分页存储过程
begin
[转]分页存储过程
select top (@PageSize* from #table where id not in(select top(@PageSize*(@PageIndex-1)) id from #table)
[转]分页存储过程
end
[转]分页存储过程
[转]分页存储过程

原:http://www.cnblogs.com/qfb620/archive/2008/02/26/1081974.html

相关文章: