SQL 명령문레코드
-------------        ——————————
if exists(select * from sysobjects where name='pading') --      pading    
drop procedure pading --     
go
create procedure pading		--      pading
							--    
	@currentPage int=0,		--    ,    0,    
	@pageSize int=5,		--       ,    5
	@countPage int output,	--    ,     
	@countRows int output	--    ,      
as
select top (@pageSize) * from temp	--    @pageSize        
where id not in (select top (@pageSize*@currentPage) id from temp ) 
order by id
set @countRows=(select count(*) from temp)	--  。          
set @countPage=@countRows/@pageSize	--  。        
if @countRows%@pageSize<>0	--  :               0
set @countPage=@countPage+1 --  +1
---------------end------------------------------------------------------------------------
---------------        -----------
declare @countpage int,@countrows int
exec pading 0,5,@countpage output,@countrows output
select @countpage,@countrows
---------------end------------------------------------------------------        (  sql  )------------------------------------
--    :2011-08-26
--  :qingyun1029
if exists (select * from sysobjects where name='splitpage')
drop procedure splitpage
go
create procedure splitpage	
	@pageSize int=10,
	@currentPage int =0,
	@countRecord int output,
	@countPage int output
as
declare @sql nvarchar(1000)
--  :  sql   ,             +   ,   cast  ,  :
set @sql=N'select top '+cast(@pageSize as nvarchar(10))
		 +' * from temp where id not in (select top '
		 +cast((@pageSize*@currentPage) as nvarchar(10))+' id from temp)'
exec sp_executesql @sql
set @countRecord=(select count(*) from temp)
set @countPage=@countRecord/@pageSize
if(@countRecord%@pageSize<>0)
set @countPage=@countPage+1
------------------------------      ------------------------------------
declare @cRecord int, @cPage int
exec splitpage 500,2,@cRecord output,@cPage output
select @cRecord,@cPage
--------------------------------end-----------------------------------------------2, sql에서 사용 순환, 테스트 데이터 삽입
declare @star int
set @star=0
while @star<100000
begin
	insert into temp
	values('qingyun',24)
	set @star=@star+1
end이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.