/*
exec IbComAddress_Select 1,8,1,1
*/
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO
ALTER PROCEDURE IbComAddress_Select
@CreatedUserID int,
@pagesize int,
@pageindex int,
@docount int
AS
set nocount on
declare @strSql varchar(3000)
if(@docount=1)
begin
set @strSql='Select count(*) from '
+'(select CustomerName , phone,'' HomePhone,'' Mobile from CustomerInfomation where CreatedUserID='+cast(@CreatedUserID as varchar(50))+
' union all select [Name],JobPhone,HomePhone,Mobile from CustomerContactor where CreatedUserID='+cast(@CreatedUserID as varchar(50))+')a'
print @strSql
--exec(@strSql)
end
else
begin
declare @indextable table(id int identity(1,1),nid int,CustomerName varchar(50),phone varchar(50),HomePhone varchar(50),Mobile varchar(50))--声明临时表
declare @PageLowerBound int
declare @PageUpperBound int
set @PageLowerBound=(@pageindex-1)*@pagesize
set @PageUpperBound=@PageLowerBound+@pagesize
set rowcount @PageUpperBound
insert into @indextable(nid,CustomerName,phone,HomePhone,Mobile)
select CustomerID, CustomerName , phone,'' HomePhone,'' Mobile from CustomerInfomation where CreatedUserID=@CreatedUserID
union all
select CustomerID, [Name],JobPhone,HomePhone,Mobile from CustomerContactor where CreatedUserID=@CreatedUserID
select * from @indextable t where t.id>@PageLowerBound and t.id <=@PageUpperBound order by t.id
end
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO