CREATE Procedure [dbo].[Pr_RunSQL]
(
	@sql nText
)
as
	EXEC (@sql)
	
GO

CREATE procedure [dbo].[StoredProcedureconfig]
(
@tab nvarchar(500),
@total nvarchar(3000),
@sort nvarchar(50),
@kid nvarchar(1000)
)
as
begin
set nocount on
declare 
@sql nvarchar(1000)
set @sql='select '+@kid+' from '+@tab+' where '+@total+' '+@sort
EXEC (@sql)
end
GO

CREATE procedure [dbo].[listpagetext]
(
@pagerows int,    
@pageindex int,
@tab nvarchar(250),
@keyid nvarchar(50),
@total nvarchar(4000),
@sort nvarchar(50),
@kid nvarchar(400),
@tt  nvarchar(50),
@rows int output
)
as
begin
set nocount on
declare 
@befrows int,
@sql nvarchar(4000)
set @befrows=@pagerows*(@pageindex-1)
set @sql='select top '+cast(@pagerows as nvarchar(50))+' '+@kid+' from '+@tab+' where '+@total+' and '+@keyid+' not in (select top '+cast(@befrows as nvarchar(50))+' '+@keyid+' from '+@tab+' where '+@total+' '+@sort+' )   '+@sort+''
EXEC (@sql)
--print @sql
-------总条数------
set @sql=N'select @rows=count('+@tt+') from '+@tab+' where '+@total+'  '+''
exec sp_executesql @sql,N'@rows int out',@rows out
select  @rows
return @rows
end