ALTER proc [dbo]. [COMMON_PROC_TEMP2]
As begin
declare @id varchar ()
declare @cbcontractid varchar;
DECLARE @ XH int;
Declare owner_03_cursor cursor scroll
for select ID from cb_contract where canton_id like ' 20% '
--2. Open Cursor
Open Owner_03_cursor
Fetch next from owner_03_cursor into @cbcontractid the number of variables in the--into must be the same as the number of columns in the cursor query result set
while @ @fetch _status=0--extraction succeeds, extract operation for next data
Begin
Set @xh =1
Declare owner_04_cursor cursor scroll
for select ID from CB _contract_change where [email protected] ORDER by BGRQ ASC
Open Owner_04_cursor
Fetch NEXT from owner_04_curs or into @id
while @ @fetch_status =0
Begin
Update cb_contract_change set [email protected] where [email&nb Sp;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 Procedure-cursors