我正在尝试更新文本字段。将数据移动到另一列并截断,因为它太长了。
更新语句如下所示。(已编辑)
UPDATE Feuil1 SET [Occupant 2] = SWITCH
(
[Occupant 2] IS NOT NULL, [Occupant 3],
(LEN([Occupant 1]) - LEN(REPLACE([Occupant 1], ' ', '')) = 3), mid([Occupant 1],InStr(InStr(1,[Occupant 1]," ")+1,[Occupant 1]," "),30),
(LEN([Occupant 1]) - LEN(REPLACE([Occupant 1], ' ', '')) = 4), mid([Occupant 1],InStr(InStr(1,[Occupant 1]," ")+1,[Occupant 1]," "),30),
(LEN([Occupant 1]) - LEN(REPLACE([Occupant 1], ' ', '')) = 5), mid([Occupant 1],InStr(InStr(1,[Occupant 1]," ")+1,[Occupant 1]," "),30),
(LEN([Occupant 1]) - LEN(REPLACE([Occupant 1], ' ', '')) = 6), mid([Occupant 1],InStr(InStr(1,[Occupant 1]," ")+1,[Occupant 1]," "),30),
(LEN([Occupant 1]) - LEN(REPLACE([Occupant 1], ' ', '')) = 7), mid([Occupant 1],InStr(InStr(1,[Occupant 1]," ")+1,[Occupant 1]," "),30),
(LEN([Occupant 1]) - LEN(REPLACE([Occupant 1], ' ', '')) = 2), '',
(LEN([Occupant 1]) - LEN(REPLACE([Occupant 1], ' ', '')) = 1), '',
[Occupant 1] LIKE '* & *', mid([Occupant 1],InStr(InStr(1,[Occupant 1]," ")+1,[Occupant 1]," "),30),
[Occupant 1] LIKE '* ET *', mid([Occupant 1],InStr(InStr(1,[Occupant 1]," ")+1,[Occupant 1]," "),30),
(LEN([Occupant 1]) - LEN(REPLACE([Occupant 1], ' ', '')) = 0), ''
), [Occupant 1] = SWITCH
(
(LEN([Occupant 1]) - LEN(REPLACE([Occupant 1], ' ', '')) = 3), mid([Occupant 1],1,InStr(InStr(1,[Occupant 1]," ")+1,[Occupant 1]," ")),
(LEN([Occupant 1]) - LEN(REPLACE([Occupant 1], ' ', '')) = 4), mid([Occupant 1],1,InStr(InStr(1,[Occupant 1]," ")+1,[Occupant 1]," ")),
[Occupant 1] LIKE '* & *', (replace([Occupant 1], ' & ' & mid([Occupant 1],InStr(InStr(1,[Occupant 1]," ")+1,[Occupant 1]," ")),InStr(InStr(2,[Occupant 1]," ")), '')),
[Occupant 1] LIKE '* ET *', (replace([Occupant 1], ' & ' & mid([Occupant 1],InStr(InStr(1,[Occupant 1]," ")+1,[Occupant 1]," ")),InStr(InStr(2,[Occupant 1]," ")), ''))
)
WHERE [Occupant 1] IS NOT NULL
我总是收到转换类型错误,但我不知道为什么。我正在使用自己修改的数据更新文本字段。所有涉及的列都是文本。
我尝试使用 Val()、Cstr() 函数,结果相同。
附加信息:似乎处理了一些数据,但我找不到原因。
有什么线索吗?