General information
Category:
Coding, syntax & commands
>>exec sp_executesql N' SELECT arjobhd.custno, arjobhd.customer, ISNULL(ssslsman.salespn,'''') as salespn, arjobhd.transtype, arjobtax.taxcode, IsNull(arjobhd.invno,0) as invno, arjob.ljob, bbjthead.id, ISNULL(SUM(arjob.price),0) as invoice, ISNULL(SUM(arjob.frtamt),0) as freight, CAST(00.00 AS decimal(10,2)) as tax, CAST(00.00 AS decimal(10,2)) as cost_lab, CAST(00.00 AS decimal(10,2)) as cost_mat, CAST(00.00 AS decimal(10,2)) as cost_fin, CAST(00.00 AS decimal(10,2)) as cost_pur, CAST(00.00 AS decimal(10,2)) as Totcost, CAST(00.00 AS decimal(10,2)) as TotInv, CAST(00.00 AS decimal(10,2)) as profper FROM arjobhd JOIN arjob on arjobhd.invno=arjob.invno JOIN arjobtax on arjobhd.invno=arjobtax.invno JOIN bbjthead on bbjthead.ljob=arjob.ljob JOIN ssslsman on arjobhd.salespnno=ssslsman.salespnno WHERE ( bbjthead.closedate between @P1 and @P2 AND arjobhd.invdate IS NOT NULL AND bbjthead.closedate >= arjobhd.invdate ) OR ( arjobhd.invdate between @P3 and @P4 AND bbjthead.closedate IS NOT NULL AND invdate >= bbjthead.closedate ) Group by arjobhd.custno, arjobhd.customer, ssslsman.salespn, arjobhd.transtype, arjobtax.taxcode, arjobhd.invno, arjob.ljob, bbjthead.id ORDER by arjob.ljob, arjobhd.invno ',N'@P1 datetime,@P2 datetime,@P3 datetime,@P4 datetime','2010-06-01 00:00:00:000','2010-06-30 00:00:00:000','2010-06-01 00:00:00:000','2010-06-30 00:00:00:000'
>
>Seems Ok to me. Try now to copy it and run in SSMS.
Results
Msg 0, Level 11, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
Msg 0, Level 20, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only