Skip to Content
0
Former Member
Mar 10, 2009 at 12:51 PM

Variables in SBO Query Generator

267 Views

Hi Expert,

I have created a VIEW in SQL and querying this via SBO. I need to use FROM and TO Date inputs from the user.

When using '[%0]' like I normally do, the query does not run.

{/code}

Declare @DateFrom as DateTime

Declare @DateTo as DateTime

Set @DateFrom = '[%0]'

Set @DateTo = '[%1]'

SELECT EARNER, PRODUCTLINE, Sum(LINETOTAL) AS 'Total', Sum(COMMISSION_PAYABLE) AS 'Total Commission'

FROM [dbo].[COMMISSION]

WHERE ([dbo].[COMMISSION].[DocDate] >= @DateFrom

AND [dbo].[COMMISSION].[DocDate] <= @DateTo)

Group by EARNER, PRODUCTLINE

ORDER BY EARNER, PRODUCTLINE

{/code}