Skip to Content
0
Former Member
Mar 22, 2011 at 09:48 PM

Sales Order + Activity query

101 Views

Hi,

I set up the following query in one company:

SELECT T0.DocNum, T1.ClgCode, T3.U_NAME, T2.name, T1.endDate, T1.Priority, T0.CardCode, T0.CardName, T0.NumAtCard, T0.DocDate, T0.DocTotal

FROM ORDR T0 LEFT OUTER JOIN OCLG T1 ON T0.DocNum = T1.DocNum LEFT OUTER JOIN OCLA T2 ON T1.status = T2.statusID LEFT OUTER JOIN OUSR T3 ON T1.AttendUser = T3.INTERNAL_K

WHERE T0.DocStatus = 'O'

When I replicate it in another company, I get the following error:

SQL Server Native Client 10.0|| SQL Server|| Conversion failed when converting the nvarchar value 'STBs-EN-0002' to data type int. 'Received Alerts' (OAIB)

The STBs value indicated is an Item Code/IMD record which isn't even referred to in the query so not sure why it's getting picked up and/or causing an error.

When I separate the two parts of the query - one query on just open sales orders, another on activities - they both work. It seems to be with the linking of ORDR to the Activities tables (if I try just ORDR and OCLG I get the same error above).

Any assistance on figuring out how to fix the query would be much appreciated,

Heather