Dear All,
I write some simple SQL reports in Excel by embedding the SQL within the command text box.
I have some SQL which works outside of Excel but when added to Excel with a parameter I get the following error:-
[Microsoft][SQL Native Client] The multi-part identifier "jobopdtl.oprseq" cannot be bound."
The query is as follows:-
select joboper.jobnum,
joboper.opcode,
joboper.estprodhours,
joboper.prodlabrate,
(joboper.estprodhours * joboper.prodlabrate)+joboper.estunitcost,
joboper.actlabcost,
opcomplete,
prodcode,
resourceid,
(select top 1 employeenum
from labordtl
where joboper.jobnum = labordtl.jobnum
and joboper.opcode = labordtl.opcode
and not employeenum = 'DUMMY'
order
by labordtlseq desc
) as 'Employee'
from jobhead
join joboper
on jobhead.company = joboper.company
join jobopdtl
on jobhead.company = jobopdtl.company
and jobhead.jobnum = joboper.jobnum
and jobhead.jobnum = jobopdtl.jobnum
and jobopdtl.assemblyseq = joboper.assemblyseq
AND jobopdtl.oprseq = joboper.oprseq
where jobhead.closeddate = ?
and joboper.jobnum like '5%'
and jobhead.company = 'SF03'
AND subcontract = 0
order by joboper.jobnum, joboper.opcode
If I remove the nested query it seems to work and if I remove the parameter it seems to work!
Anybody have any ideas?
Thanks
Lee
I write some simple SQL reports in Excel by embedding the SQL within the command text box.
I have some SQL which works outside of Excel but when added to Excel with a parameter I get the following error:-
[Microsoft][SQL Native Client] The multi-part identifier "jobopdtl.oprseq" cannot be bound."
The query is as follows:-
select joboper.jobnum,
joboper.opcode,
joboper.estprodhours,
joboper.prodlabrate,
(joboper.estprodhours * joboper.prodlabrate)+joboper.estunitcost,
joboper.actlabcost,
opcomplete,
prodcode,
resourceid,
(select top 1 employeenum
from labordtl
where joboper.jobnum = labordtl.jobnum
and joboper.opcode = labordtl.opcode
and not employeenum = 'DUMMY'
order
by labordtlseq desc
) as 'Employee'
from jobhead
join joboper
on jobhead.company = joboper.company
join jobopdtl
on jobhead.company = jobopdtl.company
and jobhead.jobnum = joboper.jobnum
and jobhead.jobnum = jobopdtl.jobnum
and jobopdtl.assemblyseq = joboper.assemblyseq
AND jobopdtl.oprseq = joboper.oprseq
where jobhead.closeddate = ?
and joboper.jobnum like '5%'
and jobhead.company = 'SF03'
AND subcontract = 0
order by joboper.jobnum, joboper.opcode
If I remove the nested query it seems to work and if I remove the parameter it seems to work!
Anybody have any ideas?
Thanks
Lee