如何从varchar(100)修剪特定字符串 [英] How to trim a particular string from a varchar(100)

查看:115
本文介绍了如何从varchar(100)修剪特定字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个名为Sentence varchar(100)的栏目

它包含的数据为

名字,姓氏:在01/01/2017被激活



名字,姓氏:已下载于01 / 01/2017



名字,姓氏:01/01/2017删除



名字,姓氏:在01/01/2017停用



 名字,姓氏:生于01/01/2017







在这里,我会喜欢qrite一个sql查询来显示每个字符串

名字,姓氏:已激活



< pre>名字,姓氏:出生





我要删除字符串从约会......所以





能帮助我吗?如何为此编写一个sql server查询。



我尝试过:



TRIM,SUBSTRING。

我无法将字符串从on ...删除到结尾。

解决方案

试试这个:

  SELECT  SUBSTRING(句子, 1 ,PATINDEX(' %ON%',句子))


Hi,
I have a column called "Sentence varchar (100)"
it contains the data as

"first name, last name : is Activated on 01/01/2017 "


"first name, last name : is Downloaded on 01/01/2017 "


"first name, last name : is Deleted on 01/01/2017 "


"first name, last name : is Deactivated on 01/01/2017 "


"first name, last name : is Born on 01/01/2017 "




Here I would like to qrite a sql query to show the every string as

"first name, last name : is Activated"


<pre>"first name, last name : is Born"



I want to remove the string from "on date...... so"


Can you please help me with this. how to write a sql server query for this.

What I have tried:

TRIM, SUBSTRING.
I'm unable to remove the string from "on ..." to end.

解决方案

Try this:

SELECT SUBSTRING(Sentence, 1, PATINDEX('% ON %',Sentence))


这篇关于如何从varchar(100)修剪特定字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆