如何在 SQL Server 中的特定字符后拆分字符串并将此值更新为特定列 [英] How to split a string after specific character in SQL Server and update this value to specific column

查看:26
本文介绍了如何在 SQL Server 中的特定字符后拆分字符串并将此值更新为特定列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一列数据 1/11/20 的表格.我想要 1 到 20 的值,即'/'(前斜杠)更新到 SQL Server 中同一个表中的其他列之后的值.

I have table with data 1/1 to 1/20 in one column. I want the value 1 to 20 i.e value after '/'(front slash) is updated into other column in same table in SQL Server.

示例:

列有值 1/1,1/2,1/3...1/20
新的列值 1,2,3,..20

也就是说,我想更新这个新列.

That is, I want to update this new column.

推荐答案

试试这个:

UPDATE YourTable
SET Col2 = RIGHT(Col1,LEN(Col1)-CHARINDEX('/',Col1))

这篇关于如何在 SQL Server 中的特定字符后拆分字符串并将此值更新为特定列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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