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

推荐订阅源

K
Kaspersky official blog
Martin Fowler
Martin Fowler
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V
Visual Studio Blog
博客园_首页
Engineering at Meta
Engineering at Meta
The Cloudflare Blog
MongoDB | Blog
MongoDB | Blog
Blog — PlanetScale
Blog — PlanetScale
T
The Blog of Author Tim Ferriss
雷峰网
雷峰网
D
Docker
博客园 - 司徒正美
S
SegmentFault 最新的问题
M
MIT News - Artificial intelligence
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
U
Unit 42
J
Java Code Geeks
A
About on SuperTechFans
N
Netflix TechBlog - Medium
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security Affairs
I
Intezer
Cisco Talos Blog
Cisco Talos Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
B
Blog RSS Feed
P
Privacy & Cybersecurity Law Blog
T
Tenable Blog
T
Threatpost
H
Hacker News: Front Page
G
Google Developers Blog
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
Apple Machine Learning Research
Apple Machine Learning Research
L
Lohrmann on Cybersecurity
大猫的无限游戏
大猫的无限游戏
Google DeepMind News
Google DeepMind News
A
Arctic Wolf
S
Secure Thoughts
GbyAI
GbyAI
NISL@THU
NISL@THU
S
Security @ Cisco Blogs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Webroot Blog
Webroot Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
O
OpenAI News
Spread Privacy
Spread Privacy
Application and Cybersecurity Blog
Application and Cybersecurity Blog

雾非雾 - 取文本

暂无文章

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

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'

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