[英]copy part of string from one column into another
I've got a column with some string data that somewhere has 'T##' (## being a two digit number) I want to copy this into another column, how do I do that? 我有一列包含一些字符串数据的列,该字符串数据的某处具有“ T ##”(##是两位数字),我想将此复制到另一列中,我该怎么做?
something like this: abc-T03-def
-> 03
像这样:
abc-T03-def
> 03
For Microsoft SQL Server: 对于Microsoft SQL Server:
update YourTable
set NewColumn = substring(OldColumn, patindex('%T[0-9][0-9]%', OldColumn) + 1, 2)
where patindex('%T[0-9][0-9]%', OldColumn) <> 0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.