<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:wfw="http://wellformedweb.org/CommentAPI/">
<channel>
<title>雾非雾 - 修改内容</title>
<link>https://www.941741.xyz/tag/%E4%BF%AE%E6%94%B9%E5%86%85%E5%AE%B9/</link>
<atom:link href="https://www.941741.xyz/feed/tag/%E4%BF%AE%E6%94%B9%E5%86%85%E5%AE%B9/" rel="self" type="application/rss+xml" />
<language>zh-CN</language>
<description></description>
<lastBuildDate>Tue, 18 Oct 2022 13:44:00 +0800</lastBuildDate>
<pubDate>Tue, 18 Oct 2022 13:44:00 +0800</pubDate>
<item>
<title>SQL 语句之取文本内容</title>
<link>https://www.941741.xyz/archives/83.html</link>
<guid>https://www.941741.xyz/archives/83.html</guid>
<pubDate>Tue, 18 Oct 2022 13:44:00 +0800</pubDate>
<dc:creator>花非花</dc:creator>
<category><![CDATA[应用技巧]]></category>
<description><![CDATA[工作需要，前几天要尝试把数据库中的一张表的两列加上后缀内容标识，摸索了一下，命令如下：先查看表 BAK1 中，BAK17 有效期设置为 9999-06-01 到 9999-06-30 之间的内容...]]></description>
<content:encoded xml:lang="zh-CN"><![CDATA[
<p><img src="https://www.941741.xyz/usr/uploads/2022/10/1229263813.png" alt="SQL Server" title="SQL Server"></p><p>工作需要，前几天要尝试把数据库中的一张表的两列加上后缀内容标识，摸索了一下，命令如下：</p><p>先查看表 BAK1 中，BAK17 有效期设置为 9999-06-01 到 9999-06-30 之间的内容。</p><pre><code>select * from BAK1 where BAK17 between &#039;9999-06-01 09:45:05.000&#039; and &#039;9999-06-30 09:45:05.000&#039; </code></pre><p>这个用来确定要修改的范围，预先查看一下，避免修改错误。<br>判断内容没问题后，修改表 BAK1 的 BAK05 列；在以列原先内容的基础上加上后缀标识“-作废”，命令如下：</p><pre><code>update BAK1 set BAK05 = BAK05+&#039;-作废&#039; where BAK17 between &#039;9999-06-01 09:45:05.000&#039; and &#039;9999-06-30 09:45:05.000&#039;</code></pre><hr><p>现在想尝试还原，思路是：取文本左边（文本内容，开始字符位，文本内容总长度-“-作废”的文本长度）<br>尝试了几次，最终命令如下：</p><pre><code>update BAK1 set BAK05 = SUBSTRING( BAK05,0,DATALENGTH(BAK05)-4) where BAK17 between &#039;9999-06-01 09:45:05.000&#039; and &#039;9999-06-30 09:45:05.000&#039;</code></pre><p>结果还算成功，以我当下的编程水平，倒也判断不出语句是否冗余。</p>
]]></content:encoded>
<slash:comments>0</slash:comments>
<comments>https://www.941741.xyz/archives/83.html#comments</comments>
<wfw:commentRss>https://www.941741.xyz/feed/tag/%E4%BF%AE%E6%94%B9%E5%86%85%E5%AE%B9/archives/83.html</wfw:commentRss>
</item>
</channel>
</rss>