Incorrect Syntax

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hello all,

I am not a SQL guy, so a lil hep is needed.

When I run the following in QA...

SELECT TOP 10 SUBSTRING(C.CASE_TITLE, 0, 20) + '...' AS LinkText,
'Modules/HD/ViewTicket.aspx?ticket=' + CONVERT(varchar(10), C.CASE_ID) AS
LinkURL,
S.STATUS_TITLE + '-' + ISNULL(P.PRIORITY_NAME, 'No
Priority') + '-' + ISNULL(CONVERT(VARCHAR(50), C.CASE_DATE_DUE), 'No Due
Date')
AS Context
FROM CASES C INNER JOIN
USERS U ON U.USER_ID = C.USER_REF_ASSIGNED INNER JOIN
STATUSES S ON S.STATUS_ID = C.CASE_STATUS LEFT OUTER
JOIN
PRIORITIES P ON C.PRIORITY_REF = P.PRIORITY_ID
WHERE S.STATUS_TITLE <> 'Closed' AND U.USER_LOGIN = lower({ 0 })
ORDER BY C.CASE_DATE_DUE DESC, C.CASE_DATE_ADD ASC

I get the following result:

Server: Msg 107, Level 16, State 2, Line 1
The column prefix 'C' does not match with a table name or alias name used in
the query.
Server: Msg 107, Level 16, State 1, Line 1
The column prefix 'C' does not match with a table name or alias name used in
the query.
Server: Msg 107, Level 16, State 1, Line 1
The column prefix 'S' does not match with a table name or alias name used in
the query.
Server: Msg 107, Level 16, State 1, Line 1
The column prefix 'P' does not match with a table name or alias name used in
the query.
Server: Msg 107, Level 16, State 1, Line 1
The column prefix 'C' does not match with a table name or alias name used in
the query.


I presume that 'C' etc is short for table names? When I replace them with
actual names, I get:

[Microsoft][ODBC SQL Server Driver]Syntax error or access violation

Could someone please point me in the right direction?

Thanks,
Jake


.



Relevant Pages