Skip to content
Advertisement

Msg 4145, Level 15, State 1, Line 5 An expression of non-boolean type specified in a context where a condition is expected, near ‘ucell’

I am trying to add another column using LEFT JOIN after ON as I want to look join multiple columns

So I tried using some thing like this

UPDATE [toolDB].[dbo].[esn_missing_in_DF_umts] 
SET [toolDB].[dbo].[esn_missing_in_DF_umts].[target_rnc] = 
             (CASE 
                 WHEN ESN_M_UMTS.target_vendor = 'HUA' 
                    THEN umts_carrier.rnc 
                    ELSE SHO.ucell_rnc 
              END)
FROM [toolDB].[dbo].[esn_missing_in_DF_umts] ESN_M_UMTS
LEFT JOIN [toolDB].[dbo].[df_umts_carrier] umts_carrier ON  ESN_M_UMTS.n_cell_name = umts_carrier.cell_name_umts
LEFT JOIN [toolDB].[dbo].[esn_umts_intra_sho] SHO ON ESN_M_UMTS.n_cell_name = SHO.[urelation] OR SHO.ucell

and I get this error:

Msg 4145, Level 15, State 1, Line 5
An expression of non-boolean type specified in a context where a condition is expected, near ‘ucell’.

The error must be in this part:

LEFT JOIN [toolDB].[dbo].[esn_umts_intra_sho] SHO ON ESN_M_UMTS.n_cell_name = SHO.[urelation] OR SHO.ucell

Does anyone have an idea how to solve this?

Advertisement

Answer

This is not valid T-SQL (or at least, will not do what you want):

ON ESN_M_UMTS.n_cell_name = SHO.[urelation] OR SHO.ucell

Ths treats OR SHO.ucell as a separate condition, so the database tries to evaluate it in bolean context, which fails here.

You can use IN instead:

ON ESN_M_UMTS.n_cell_name IN (SHO.[urelation], SHO.ucell)
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement