SQL Server access Process cursors

Source: Internet
Author: User

ALTER proc [dbo]. [COMMON_PROC_TEMP2]

As
Begin
DECLARE @id varchar (50);
DECLARE @cbcontractid varchar (50);
declare @xh int;
DECLARE owner_03_cursor cursor Scroll
For select ID from cb_contract where canton_id like ' 20% '
--2. Opening cursors
Open Owner_03_cursor
FETCH NEXT from Owner_03_cursor to @cbcontractid--into must have the same number of columns as the cursor query result set
While @ @fetch_status = 0--fetch succeeds, fetch the next data
Begin
Set @xh =1
DECLARE owner_04_cursor cursor Scroll
For select ID from Cb_contract_change where [e-mail protected] ORDER by BGRQ ASC
Open Owner_04_cursor
FETCH NEXT from Owner_04_cursor to @id
While @ @fetch_status =0
Begin
Update Cb_contract_change set [email protected] where [email protected]
Set @[email protected]+1;
FETCH NEXT from Owner_04_cursor to @id
End
Close owner_04_cursor;
Deallocate owner_04_cursor;

FETCH NEXT from Owner_03_cursor to @cbcontractid--move cursor
End
Close owner_03_cursor;
Deallocate owner_03_cursor;
End

SQL Server access Process cursors

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.