MS Access字段拆分

时间:2017-06-08 11:54:50

标签: sql ms-access

我正在尝试在单独的列中拆分以下数据字段,例如使用“:”分隔符,

实际数据

DSLAM name:Port address 
M301-41-301_DDOW3:1-0-7-1

结果

DSLAM name  Port address
M301-41-301_DDOW3   1-0-7-1

我正在使用以下脚本,但缺少运算符语法错误。

UPDATE 14052017 SET

NodeName= left(DSLAMname:Port address, InStr( DSLAMname: Port address, ":") -1),
PortAddress= Mid(DSLAMname:Port address, InStr( DSLAM name: Port address, ":") +1);

请在此处指出错误或更好的解决方案

1 个答案:

答案 0 :(得分:0)

你可以创建一个函数:

Public Function SplitValue(ByVal value_ As Variant, ByVal index As Long) As String
    If Not IsNull(value_) Then SplitValue = Split(value_, ":")(index)
End Function

'....

UPDATE 14052017 SET
NodeName= SplitValue([DSLAMname:Port address], 0),
PortAddress= SplitValue([DSLAMname:Port address], 1);