SQL Bulk Modify Order number

Source: Internet
Author: User


Example: Now there is a requirement to replace the date 20170599 in the order number with the new date 20180699


Before modification:

SELECT * from Icstockbill where Fbillno like ' whfc201705% ' ORDER by Fbillno


Results:

Finterid FDate Fbillno

209234 2017-04-30 00:00:00.000 WHFC201705990001

209235 2017-04-30 00:00:00.000 WHFC201705990002

209236 2017-04-30 00:00:00.000 WHFC201705990003

209237 2017-04-30 00:00:00.000 WHFC201705990004

.......

209239 2017-04-30 00:00:00.000 WHFC2017059900999



After modification

With the Replace function:

Format: repalce (field name, value to replace, new value after replacement)

If you replace a specific value, you can replace the field with the corresponding value, or specify it by condition.


Update Icstockbill Set Fbillno=replace (Fbillno, ' 20170508 ', ' 20180510 ') where Fbillno between ' WHFC201705080001 ' and ' WHFC201705089999 '


Finterid FDate Fbillno

209234 2017-04-30 00:00:00.000 WHFC201806990001

209235 2017-04-30 00:00:00.000 WHFC201806990002

209236 2017-04-30 00:00:00.000 WHFC201806990003

209237 2017-04-30 00:00:00.000 WHFC201806990004

......

209239 2017-04-30 00:00:00.000 WHFC201806990999


In order to achieve this function, Baidu also walked not detours, special leave this article, only for record, hope to help people who need.



SQL Bulk Modify Order number

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.