Use the stored procedure to implement paging printing.
This stored procedure is a cell broadband user management system, part of the code in the project.
The function is: implement the user information in the table USERINFO, select the IP network segment to make a paging print! ! For example, 172.20.128.xx's IP is referred to as a 128 network segment, 172.20.119.xx's IP is referred to as a user of the 119 network segment,
Users in each network segment are printed on a A4 paper, not enough to print, and the rest can be empty. It is more than one-sheet printing, and the remaining empty out. After estimating one page, only 37 lines can only be printed. The idea is: first put the select of the user information and the calculated space line insert into one. The temporary table is then printed more.
- First empty table - Truncate Table Subip
Declare @Result int declare @subip varchar (20) Declare cur_e scroll cursor for select substring (ip_address, 8, 3) from userinfo group by substring (ip_address, 8, 3)
Open cur_e - Open Cursor --Print 'AAA' Convert (Char (13), @@ Cursor_ROWS) Fetch First from Cur_e Into @subip
while (@@ fetch_status = 0) begin --insert into subip (supip) values (@subip) insert into subip select userinfo.username, userinfo.catalyst_port, userinfo.home_address, userinfo.ip_address, userinfo.phone, catalyst.label, '' from userinfo, catalyst where userinfo.catalyst_id = Catalyst.id and substring (userinfo.ip_address, 8, 3) @ @ Subip set @Result = @@ rowcount if (@Result> 37) Begin While (@Result <74) Begin Insert Into Subip Select
Username = ', catalyst_port =' ', homen_address =' ', ip_address =', phone = ', label =', account = '' set @ result = @ result 1 end end Else Begin While (@Result) <37) Begin Insert Into Subip Select