Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用sql server修剪字符串中大写字符之前的所有小写字符_Sql_Sql Server - Fatal编程技术网

如何使用sql server修剪字符串中大写字符之前的所有小写字符

如何使用sql server修剪字符串中大写字符之前的所有小写字符,sql,sql-server,Sql,Sql Server,如何编写SQL Server查询来修剪字符串中第一个大写字符之前的所有小写字符? e、 g.字符串值“eaplgCostPrice”,删除“eaplg”并将“CostPrice”传递到新列如果与某些排序规则结合使用,则它可以根据大小写运行 示例代码片段: -- -- using a table variable for demonstration purposes -- declare @Table table (id int identity(1,1), col varchar(30)); i

如何编写SQL Server查询来修剪字符串中第一个大写字符之前的所有小写字符? e、 g.字符串值“eaplgCostPrice”,删除“eaplg”并将“CostPrice”传递到新列

如果与某些排序规则结合使用,则它可以根据大小写运行

示例代码片段:

--
-- using a table variable for demonstration purposes
--
declare @Table table (id int identity(1,1), col varchar(30));
insert into @Table (col) values ('eaplgCostPrice'),('SellPrice'),('amount');

--
-- trim leading lowercases when needed
--
select col, 
(case
 when patindex('[a-z]%[a-z][A-Z]%', col COLLATE Latin1_General_Bin) > 0
 then substring(col, patindex('%[A-Z]%', col COLLATE Latin1_General_Bin), len(col))
 else col
 end) as trimmedCol
from @Table
col             trimmedCol
------------------  ----------------
eaplgCostPrice  CostPrice
SellPrice       SellPrice
amount          amount
结果:

--
-- using a table variable for demonstration purposes
--
declare @Table table (id int identity(1,1), col varchar(30));
insert into @Table (col) values ('eaplgCostPrice'),('SellPrice'),('amount');

--
-- trim leading lowercases when needed
--
select col, 
(case
 when patindex('[a-z]%[a-z][A-Z]%', col COLLATE Latin1_General_Bin) > 0
 then substring(col, patindex('%[A-Z]%', col COLLATE Latin1_General_Bin), len(col))
 else col
 end) as trimmedCol
from @Table
col             trimmedCol
------------------  ----------------
eaplgCostPrice  CostPrice
SellPrice       SellPrice
amount          amount

这可能会有帮助(SQL Server):是的,SQL Server。字符串值“eaplgCostPrice”,删除“eaplg”并将“CostPrice”传递给新列