Skip to Content
0
Former Member
Oct 23, 2011 at 11:35 PM

Need help on derived table

27 Views

Hi Experts,

When I create the derived table, I got this error message.

Exception: DBD, [Microsoft][ODBC SQL Server Driver]Communication link failureState:08S01

But I can run the query in SQLServer management Studio successfully.

What kind of syntax I should follow?

The following is the script:

select INV. docdate as 'Date', sum(INV.doctotal) as 'Total' from OINV INV

where INV.docdate >= dateadd(day, -14,convert(date,getdate())) and INV.docdate < dateadd(day, 1,convert(date,getdate()))

group by INV.docdate

union

select CR.docdate as 'Date', sum(CR.doctotal*-1) as 'Total' from ORIN CR

where CR.docdate >= dateadd(day, -14,convert(date,getdate())) and CR.docdate < dateadd(day, 1,convert(date,getdate()))

group by CR.docdate

Derived table cannot recognize dateadd() ?

Thanks,

Christina