Question : Server: Msg 170

Hi,
I have a sql view, which i need to retrieve information. Question: I need three different names and surnames from the users table. The one who accepted the quote, who opened the quote and last who the quote has been assigned to.

The Error that i get is this;
Server: Msg 170, Level 15, State 1, Line 25
Line 25: Incorrect syntax near 'QuoteID'.

I appreciate the help.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
SELECT dbo.Quotes.QuoteName, dbo.QuoteStatus.Description AS Status, dbo.QuoteAccepted.AcceptDate, dbo.a.FirstName+' '+dbo.a.LastName as [Accepted By], dbo.o.FirstName+' '+dbo.o.LastName as [Opened By], 
dbo.QuoteNotes.Note, dbo.QuoteNotes.NoteDate, dbo.ato.FirstName+' '+dbo.ato.LastName as [Assigned To], dbo.QuoteFollowUPs.LastFollowup, 
dbo.QuoteFollowUPs.NextFollowUp, dbo.QuoteFollowUPs.Comment, dbo.QuoteFollowUPs.HoursSpent, dbo.QuoteFollowUPs.DaysSpent, 
dbo.QuoteBookingReferences.BookRef, dbo.QuoteTourTypes.Description AS [Tour Type], dbo.QuoteTypes.Description AS [Quote Type], dbo.Quotes.QuoteID, dbo.QuotesSent.DateSent, dbo.QuotesSent.Cost, dbo.QuotesSent.PaxFrom, 
dbo.QuotesSent.PaxTo, dbo.QuotesSent.Currency, dbo.QuotesSent.Selling, dbo.QuotesSent.MasterPaxAmount
FROM dbo.QuoteBookingReferences INNER JOIN
dbo.Quotes INNER JOIN
dbo.QuoteStatus_Quotes ON dbo.Quotes.QuoteID = dbo.QuoteStatus_Quotes.QuoteID INNER JOIN
dbo.QuoteStatus ON dbo.QuoteStatus_Quotes.StatusID = dbo.QuoteStatus.StatusID ON 
dbo.QuoteBookingReferences.QuoteID = dbo.Quotes.QuoteID INNER JOIN
dbo.QuoteFollowUPs ON dbo.Quotes.QuoteID = dbo.QuoteFollowUPs.QuoteID INNER JOIN
dbo.QuoteNotes ON dbo.Quotes.QuoteID = dbo.QuoteNotes.QuoteID INNER JOIN
dbo.QuoteOpenedBy ON dbo.Quotes.QuoteID = dbo.QuoteOpenedBy.QuoteID INNER JOIN
dbo.Quotes_QuoteTourTypes ON dbo.Quotes.QuoteID = dbo.Quotes_QuoteTourTypes.QuoteID INNER JOIN
dbo.QuoteTourTypes ON dbo.Quotes_QuoteTourTypes.TypeofToursID = dbo.QuoteTourTypes.TypeofToursID INNER JOIN
dbo.Quotes_QuoteTypes ON dbo.Quotes.QuoteID = dbo.Quotes_QuoteTypes.QuoteID Inner JOIN
dbo.QuoteTypes ON dbo.Quotes_QuoteTypes.TypeofQuoteID = dbo.QuoteTypes.TypeofQuoteID INNER JOIN
dbo.QuotesSent ON dbo.Quotes.QuoteID = dbo.QuotesSent.QuoteID LEFT OUTER JOIN
/*Trying to use the same table to get back different names and surnames*/
dbo.Users INNER JOIN
dbo.Users a INNER JOIN
dbo.Users o INNER JOIN
dbo.Users ato INNER JOIN
dbo.QuoteAccepted ON dbo.a.UserID = dbo.QuoteAccepted.UserID INNER JOIN
dbo.QuoteAssignTo ON dbo.ato.UserID = dbo.QuoteAssignTo.UserID ON dbo.QuoteOpenedBy.UserID = dbo.o.UserID AND 
dbo.Quotes.QuoteID = dbo.QuoteAssignTo.QuoteID AND dbo.Quotes.QuoteID = dbo.QuoteAccepted.QuoteID
Open in New Window Select All

Answer : Server: Msg 170

comment out all your JOIN and add them one by one.

I see right at the beginning that you don't have the ON clause again:

FROM dbo.Users INNER JOIN
dbo.QuoteBookingReferences INNER ...

so comment out every JOINs and add them one by one (ensuring it is working before adding another one)
Random Solutions  
 
programming4us programming4us