Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Stored Procedure
Message
 
 
To
26/07/2010 17:41:10
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01473624
Message ID:
01474021
Views:
32
>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.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform