Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8295485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:36:33+00:00 2026-06-08T14:36:33+00:00

Msg 156, Level 15, State 1, Line 107 Incorrect syntax near the keyword ‘on’.

  • 0
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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T14:36:35+00:00Added an answer on June 8, 2026 at 2:36 pm

    Here is a reformatting of your SQL that might make it a bit more clear what your issue is:

    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
    

    It looks like you are missing a second ) before SplitAddresses to make it:

    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
                ) SA
        ) SplitAddresses
        on SplitAddresses.Client_id=d_client.CLIENT_ID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Query gives me some error: Msg 156, Level 15, State 1, Line 4 Incorrect
This Codes give me error: Msg 156, Level 15, State 1, Procedure DefaultActivity, Line
Msg 701, Level 17, State 123, Line 1 There is insufficient system memory to
I get the error: Msg 2714, Level 16, State 1, Line 16 There is
i am getting the error as shown below : Msg 156, Level 15, State
Below mentioned stored procedure is giving error while creating Msg 156, Level 15, State
Why does my procedure give me: Msg 156, Level 15, State 1, Procedure CountAantalModules,
Msg 245, Level 16, State 1, Line 89 Conversion failed when converting the varchar
error list Msg 4866, Level 16, State 7, Line 2 The bulk load failed.
syntax error: msg = keyword can't be an expression offset = None print_file_and_line =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.