T-SQL Find char string and take all char to right of expression(T-SQL 查找字符字符串并将所有字符移到表达式的右侧)
问题描述
我该怎么办
采取:
RJI#\\\\Cjserver\TrialWorks\CaseFiles\10000269\Pleadings\RJI - 10005781.doc
找到常量表达式 '\\Cjserver\' 并将所有内容放在表达式的右侧,因此正确的指针是:
Find Constant expression '\\Cjserver\' and take everything to the right of the expression so the correct pointer would be:
\\\\Cjserver\TrialWorks\CaseFiles\10000269\Pleadings\RJI - 10005781.doc
我知道RIGHT 和CHARINDEX 的某种组合应该可以做到这一点.
I know some kind of combinaton of RIGHT and CHARINDEX should do it.
推荐答案
DECLARE @input NVarChar(1000) =
'RJI#\\Cjserver\TrialWorks\CaseFiles\10000269\Pleadings\RJI - 10005781.doc',
@match NVarChar(100) =
'\\Cjserver';
DECLARE @position Int = CHARINDEX(@match, @input);
SELECT SUBSTRING(@input, @position, 1000);
我只是将 1000 用于某个任意大的值.您可能应该根据您的数据调整其大小.
I'm just using 1000 for some arbitrarily large value. You should probably size this more appropriately to your data.
这篇关于T-SQL 查找字符字符串并将所有字符移到表达式的右侧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:T-SQL 查找字符字符串并将所有字符移到表达式的
基础教程推荐
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- 带更新的 sqlite CTE 2022-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
