Msg 156, Level 15, State 1, Line 107
Incorrect syntax near the keyword 'on'.
I have a fairly large query and I am going to provide only a small portion of it. I am getting a syntax error on the ON:
SplitAddresses.Client_id=d_client.CLIENT_ID
...
left join
(SELECT distinct
T.MLIS_CLIENT_ADDRESS_1,T.Client_id,
Left(T.MLIS_CLIENT_ADDRESS_1, IsNull(SplitAddresses.Pos - 1, 2147483647)) Address1,
Substring(T.MLIS_CLIENT_ADDRESS_1, SplitAddresses.Pos + 1, 2147483647) Address2
FROM
d_client
T
OUTER APPLY (
SELECT TOP 1 NullIf(PatIndex(Delimiter, T.MLIS_CLIENT_ADDRESS_1), 0) Pos
FROM (
VALUES ('% Suite %'), ('% Ste %'), ('% Bldg %'), ('% Building %'), ('%#%')
) SplitAddresses (Delimiter)
WHERE T.MLIS_CLIENT_ADDRESS_1 LIKE SplitAddresses.Delimiter
ORDER BY Pos
) SplitAddresses
on
SplitAddresses.Client_id=d_client.CLIENT_ID
WHERE...
am i doing some obviously wrong with the syntax or is there a deeper problem? thank you so much for your help.
Here is a reformatting of your SQL that might make it a bit more clear what your issue is:
It looks like you are missing a second ) before SplitAddresses to make it: