SQL Server cursor usage

Source: Internet
Author: User

Declare @ chrname varchar (30)
Declare @ chryhm varchar (30)

Declare dw_only1 cursor for -- set the cursor to retrieve the record set for operation
Select chrname, chryhm from gzry where chrzw> = 5 order by chrzw DESC, intpxh -- select the position from the front and above
Open dw_only1
While (1> 0)
Begin
Fetch dw_only1 into @ chrname, @ chryhm
If (@ fetch_status =-1)
Begin
Close dw_only1
Deallocate dw_only1
Break
End
If (@ fetch_status =-2)
Begin
Close dw_only1
Deallocate dw_only1
Break
End
--- Select @ chrname, @ chryhm
-- Grant permissions to the corresponding person
Delete from yhmkqx where chryhm = @ chryhm and chrmkbm like '123'
Insert into yhmkqx (chryhm, chrmkbm) values (@ chryhm, '123 ')

End -------- end while

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.