Sql 在';之后获取值';
我有一个这样的专栏:Sql 在';之后获取值';,sql,sql-server,Sql,Sql Server,我有一个这样的专栏: log --- smart.pc mobile.my.phone laptop.student.school dog.house pc.game.headset 我只想取“.”之后的最后一个值: log --- pc phone school house headset 我尝试使用case-when-log-like%.%来获取值,但在replace中,我不知道将什么放在旧值的位置来获取列中的所有值替换(日志,'','') 似乎它在这里也给出了答案:也许最简单的方法是使
log
---
smart.pc
mobile.my.phone
laptop.student.school
dog.house
pc.game.headset
我只想取“.”之后的最后一个值:
log
---
pc
phone
school
house
headset
我尝试使用case-when-log-like%.%
来获取值,但在replace中,我不知道将什么放在旧值的位置来获取列中的所有值<代码>替换(日志,'','')
似乎它在这里也给出了答案:也许最简单的方法是使用
string\u split()
:
是一把D小提琴。所以最后一次
?@Charlieface之后的一切都是正确的
select s.value
from t cross apply
string_split(t.log, '.') s
where t.log like '%.' + s.value;