sql - 如何解析excel文件
问题描述
我在excel中有很多行,比如
TALLON | BLACK | 44
我需要提取管道之间的值。
因此,我只需要获取BLACK
上述示例行的值。如何提取这些值?
解决方案
一种选择是使用带有(管道)的substring()
函数作为搜索表达式:charindex()
|
with t(str) as
(
select 'TALLON | BLACK | 44' union all
select 'LLON | BLUE| 47 ' union all
select 'LON |YELLOW| 56 '
)
select substring(str, charindex('|',str,1)+1,
( charindex('|',str, charindex('|',str,1)+1) - charindex('|',str,1) )-1 )
as result
from t;
result
--------
BLACK
BLUE
YELLOW
推荐阅读
- c - ESP32 如何重置与 PCNT 一起使用的 GPIO 引脚,以便它们也可用于 EXT1 从深度睡眠中唤醒?
- codenameone - Codename One 应用程序的线程计数
- python-3.x - 两个看起来应该做同样事情但输出不同结果的python循环?
- php - 为 Angular 应用程序配置 php 后端和 mysql 数据库
- java - Spring MockMVC redirectUrlPattern 抛出“No Ant-style path pattern”
- dart - Dart 2.0 中是否有任何密封类替代方案?
- react-native - Google 地方信息 API:INVALID_REQUEST
- html - 空间不足时如何分页?
- excel - 如何循环遍历范围内的一部分列中的单元格?
- c - 如何在传递控制权之前列出所有子 pid?