查找和删除字符的SQL查询

问题描述 投票:0回答:2

我正在使用 SSIS 和 SQL 从一个平面文件导入数据到一个名为 TCVS_tmp_PO_Detail 的 SQL 表。现在,我在采购订单列中得到了一些字符,我想找到并消除这些字符。

这些字符是 ï "¿,那么我是否可以将数字左边的这3个字符修剪掉?它并不是一直发生的,所以我可以在SSIS作业的前端以查询的方式运行它,在导出之前对它进行修正。

下面是一个例子,说明当它发生时是什么样子的

Purchase Order
7
7
8
8
8
8
8
8
9
10
10
10
10
11
12
13
11
12
13
14
14
15
15
16
16
17
19
18
19
20
22
sql replace ssis trim
2个回答
0
投票

我不知道处理的数据在哪里,但你可以很容易地用一个 case 表达式。

 (case when purchase_order like '%' then stuff(purchase_order, 1, 3, '')
       else purchase_order
  end) as purchase_order

0
投票

我想你是用 "数据流任务"

  1. 增加 "派生列 "组件 enter image description here
  2. 增加新栏目
  3. 将此代码添加到Expression中

    REPLACE(Purchase,"","")

结果:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.