繁体   English   中英

如何从 sql 服务器中的所有记录中删除 Last word

[英]How to remove Last word from all the records in sql server

当我这样做时,我的表名是 RJD (CMTS):

select CMTS from RJD

output:

11/24/2020 3:49:23 PM - Padhiyar, Akash  this is approved comment 3  approved
11/24/2020 3:49:11 PM - Padhiyar, Akash  this is reviewing comment 2  Reviewing
11/24/2020 3:48:58 PM - Padhiyar, Akash  this is idea comment 1  Idea

我想从所有记录中删除最后一个单词。 在 sql 中。

output应该是这样的。

11/24/2020 3:49:23 PM - Padhiyar, Akash  this is approved comment 3
11/24/2020 3:49:11 PM - Padhiyar, Akash  this is reviewing comment 2 
11/24/2020 3:48:58 PM - Padhiyar, Akash  this is idea comment 1

有人可以为此建议 sql 查询解决方案。

您可以使用:

select rtrim(left(cmts,
                  len(cmts) - charindex(' ', reverse(cmts))
                 )
           )

是 SQL 小提琴。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM