日期:2014-05-17 浏览次数:20475 次
USE [BankMan]
GO
/****** Object: StoredProcedure [dbo].[_PageQuerys1] Script Date: 05/05/2013 14:09:10 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Proc [dbo].[_PageQuerys1]
@PageIndex int, --当前第几页
@PageSize int, --每页行数
@Name nvarchar(31), --用户
@Number nvarchar(31),--银行卡号
@AccountType int, --卡类别 1、个人 2、企业
@BankName nvarchar(63), --银行名称
@OrderValue varchar(100) --排序字段
as
declare
@StrSql varchar(3000), --主查询语句
@WhereSql varchar(3000)
begin
if @Name is not null or @Name<>''
begin
set @WhereSql=N' and a.Name='''+@Name+''''
end
if @Number is not null or @Number<>''
begin
set @WhereSql=@WhereSql+N' and a.Number='''+@Number+''''
end
print @AccountType
if @AccountType<>0
begin
set @WhereSql=@WhereSql+' and a.AccountType='+@AccountType
end
if @BankName is not null or @BankName <>''
begin
set @WhereSql=@WhereSql+N' and b.BankName='''+@BankName+''''
end
if @WhereSql is null or @WhereSql=''
begin
set @WhereSql=''
end
set @StrSql=N'select abc.* from
(select ROW_NUMBER() over (order by ab.[AccountId] desc ) as rowid,ab.* from
(select a.[AccountId], b.BankName,b.Logo,a.[Name],a.[Number],a.[LastUpdateTime],
a.[MaximumLimit],a.[Current],a.[Detail],a.[CreateTime],
(case a.[Type] when 1 then ''个人'' else ''企业'' end) as AccountType ,
a.Level,(case a.[State] when 1 then ''生效'' when 2 then ''冻结'' else ''注销'' end) as AccountState
from BankAccounts as a,Banks as b
where a.[BankID]=b.[BankID] '+@WhereSql+')ab)abc
where abc.rowid>'+convert(nvarchar(50),(@PageIndex - 1) * @PageSize)+'
and abc.rowid<='+convert(nvarchar(50),(@PageIndex * @PageSize))+' '
--if @OrderValue is not null or @OrderValue <>''
-- begin
-- set @StrSql=@StrSql+' order by '+@OrderValue
-- end
--else
-- begin
-- set @StrSql=@StrSql+N' order by abc.LastUpdateTime'
-- end
exec (@StrSql)
print @StrSql
end