0

I want to upload my list box in Excel with data from SQL server.

I'm running this query on server and is working fine.

I tried to search for help on google but failed.

I have an problem with my query syntax I assume.

s = "SELECT DISTINCT(B.[Manager Name]), A.[SESA ID] " & _
"FROM [Current Job Data] AS A" & _
"LEFT JOIN [Work Relationship Report] AS B " & _
"ON B.[Manager Person Number]= A.[Employee Person Number] " & _
"INNER JOIN [Work Relationship Report] AS C ON  B.[Manager Name] = C.[Manager Name]" & _
"WHERE b.[Manager Name] Is Not Null"

When I run my query I'm getting an error message:

The multi-part identifier "A.Employee Person Number" could not be bound.

I don't know how to fix this, thank you for your help :)

1
  • DISTINCT is not a function (on a column), it's a part of SELECT DISTINCT, and applies to the whole selected rows. Remove those redundant parentheses and simply write SELECT DISTINCT B.[Manager Name]) + ... to make things clearer. Commented Apr 5, 2018 at 10:12

1 Answer 1

1

Add trailing spaces. Your whole string is a one line string.

FROM [Current Job Data] AS A" & _ "LEFT Join..."

becomes

FROM [Current Job Data] AS ALEFT Join ...

Thus there is no identifier A

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you ! I'm blind :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.