惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
N
Netflix TechBlog - Medium
腾讯CDC
C
Check Point Blog
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
S
SegmentFault 最新的问题
F
Fortinet All Blogs
美团技术团队
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
F
Full Disclosure
Recorded Future
Recorded Future
D
DataBreaches.Net
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
J
Java Code Geeks
I
InfoQ
Y
Y Combinator Blog
A
About on SuperTechFans
AI
AI
爱范儿
爱范儿
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
W
WeLiveSecurity
M
MIT News - Artificial intelligence
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
Schneier on Security
Schneier on Security
The GitHub Blog
The GitHub Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
Recent Commits to openclaw:main
Recent Commits to openclaw:main
量子位
V2EX - 技术
V2EX - 技术
Project Zero
Project Zero

雾非雾 - SQL语句

SQL 语句之 REPLACE 函数
SQL 语句之取文本内容
花非花 · 2022-10-18 · via 雾非雾 - SQL语句

SQL Server

工作需要,前几天要尝试把数据库中的一张表的两列加上后缀内容标识,摸索了一下,命令如下:

先查看表 BAK1 中,BAK17 有效期设置为 9999-06-01 到 9999-06-30 之间的内容。

select * from BAK1 where BAK17 between '9999-06-01 09:45:05.000' and '9999-06-30 09:45:05.000' 

这个用来确定要修改的范围,预先查看一下,避免修改错误。
判断内容没问题后,修改表 BAK1 的 BAK05 列;在以列原先内容的基础上加上后缀标识“-作废”,命令如下:

update BAK1 set BAK05 = BAK05+'-作废' where BAK17 between '9999-06-01 09:45:05.000' and '9999-06-30 09:45:05.000'

现在想尝试还原,思路是:取文本左边(文本内容,开始字符位,文本内容总长度-“-作废”的文本长度)
尝试了几次,最终命令如下:

update BAK1 set BAK05 = SUBSTRING( BAK05,0,DATALENGTH(BAK05)-4) where BAK17 between '9999-06-01 09:45:05.000' and '9999-06-30 09:45:05.000'

结果还算成功,以我当下的编程水平,倒也判断不出语句是否冗余。