将以下查询
的数据类型varchar转换为数字时出错请建议我可以修改哪些内容
Update BUDTANKS
set BUDTANKS.SHELLCAPACITY = 0.0000000 --Numeric Column
,BUDTANKS.WORKINGCAPACITY = 0.0000000 --Numeric Column
,BUDTANKS.LEASEDCAPACITY = 0.0000000 --Numeric Column
,BUDTANKS.VERSIONID = 1
,BUDTANKS.STATUSID = 1
,BUDTANKS.IMPORTEDRECORD = 1
,BUDTANKS.LastModifiedUserID = 'Import'
,BUDTANKS.LASTMODIFIEDDATETIME = GETDATE()
FROM BUDTANKS BTANK WITH(NOLOCK)
INNER JOIN BUDTERMINALS BT WITH(NOLOCK) ON BT.TERMINALID = BTANK.TERMINALID
INNER JOIN External_Liq_Itm_Tanks ELIT WITH(NOLOCK) ON ELIT.TerminalName = BT.MBFTERMINALNAME AND ELIT.TankName = BTANK.TANKNAME
Where (ISNULL(BTANK.SHELLCAPACITY, '') <> ISNULL(0.0000000, '')
OR ISNULL(BTANK.WORKINGCAPACITY, '') <> ISNULL(0.0000000, '')
OR ISNULL(BTANK.LEASEDCAPACITY, '') <> ISNULL(0.0000000, '')
OR (BTANK.STATUSID <> 1)
OR (BTANK.IMPORTEDRECORD <> 1))
答案 0 :(得分:1)
我认为您对此查询的问题是Where
条件:
Where (ISNULL(BTANK.SHELLCAPACITY, '') <> ISNULL(0.0000000, '')
OR ISNULL(BTANK.WORKINGCAPACITY, '') <> ISNULL(0.0000000, '')
OR ISNULL(BTANK.LEASEDCAPACITY, '') <> ISNULL(0.0000000, '')
OR (BTANK.STATUSID <> 1)
OR (BTANK.IMPORTEDRECORD <> 1))
您需要将其更改为:
Where (ISNULL(BTANK.SHELLCAPACITY, 0) <> 0)
OR ISNULL(BTANK.WORKINGCAPACITY,0) <> 0)
OR ISNULL(BTANK.LEASEDCAPACITY, 0) <> 0)
OR (BTANK.STATUSID <> 1)
OR (BTANK.IMPORTEDRECORD <> 1))
或
Where BTANK.SHELLCAPACITY Is Not Null
OR BTANK.WORKINGCAPACITY Is Not Null
OR BTANK.LEASEDCAPACITY Is Not Null
OR (BTANK.STATUSID <> 1)
OR (BTANK.IMPORTEDRECORD <> 1))