ID of a specific sort primary key added to an existing record table

Source: Internet
Author: User
  1. Declare employee_cursor cursor
  2. Select updatetime, ID
  3. From tblsimaccounthistory
  4. Order by updatetime, ID
  5. Open employee_cursor
  6. Declare @ updatetime datetime
  7. Declare @ ID decimal
  8. Declare @ hid decimal
  9. Select @ hid = 1
  10. Fetch next from employee_cursor
  11. Into @ updatetime, @ ID
  12. While @ fetch_status = 0
  13. Begin
  14. Update tblsimaccounthistory set hid = @ hid where id = @ ID and updatetime = @ updatetime
  15. Select @ hid = @ hid + 1
  16. Fetch next from employee_cursor
  17. Into @ updatetime, @ ID
  18. End
  19. Close employee_cursor
  20. Deallocate employee_cursor
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.