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

推荐订阅源

博客园 - Franky
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Schneier on Security
Know Your Adversary
Know Your Adversary
Security Latest
Security Latest
Spread Privacy
Spread Privacy
Project Zero
Project Zero
T
The Exploit Database - CXSecurity.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
AI
AI
N
News | PayPal Newsroom
A
Arctic Wolf
NISL@THU
NISL@THU
W
WeLiveSecurity
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News: Ask HN
Hacker News: Ask HN
P
Palo Alto Networks Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
大猫的无限游戏
大猫的无限游戏
L
Lohrmann on Cybersecurity
Last Week in AI
Last Week in AI
T
Threatpost
The Last Watchdog
The Last Watchdog
博客园_首页
C
Cybersecurity and Infrastructure Security Agency CISA
酷 壳 – CoolShell
酷 壳 – CoolShell
量子位
Engineering at Meta
Engineering at Meta
爱范儿
爱范儿
aimingoo的专栏
aimingoo的专栏
S
Security Affairs
P
Privacy & Cybersecurity Law Blog
B
Blog RSS Feed
AWS News Blog
AWS News Blog
P
Proofpoint News Feed
雷峰网
雷峰网
T
Tenable Blog
Schneier on Security
Schneier on Security
H
Heimdal Security Blog
V2EX - 技术
V2EX - 技术
V
V2EX
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
Secure Thoughts
Latest news
Latest news
Help Net Security
Help Net Security
Jina AI
Jina AI
Stack Overflow Blog
Stack Overflow Blog
The Cloudflare Blog
V
Vulnerabilities – Threatpost
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org

雾非雾 - 取文本

暂无文章

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'

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