Skip to Content

whats wrong in this query?

hello all,

i have the ff. query

Declare @GLCode as nvarchar(15)
Declare @FromDate as DateTime
Declare @ToDate as DateTime

set @GLCode = (SELECT T0.[AcctCode] FROM OACT T0 WHERE T0.[FormatCode] = '801010000000' and T0.GroupMask=6)
set @FromDate = (SELECT min(T1.RefDate)FROM JDT1 T1 WHERE T1.RefDate = '06/1/2010')
Set @ToDate = (SELECT min(T2.RefDate)FROM JDT1 T2 WHERE T2.RefDate = '08/31/2010')


SELECT T3.[RefDate] as 'Posting Date', T3.[TransId] as 'Origin', T4.[AcctName] as 'Acct. Name', T3.[LineMemo] as 'Details', T3.[Debit] as 'Debit Amount', T3.[Credit] as 'Credit Amount'
FROM JDT1 T3  INNER JOIN OACT T4 ON T3.Account = T4.AcctCode 

WHERE T3.[Account] = @GLCode and T3.RefDate >= @FromDate and T3.RefDate <= @ToDate

ORDER BY T3.[RefDate]

this query works fine in SQL Server but when i run this query in SBO with the ff. Query

Declare @GLCode as nvarchar(15)
Declare @FromDate as DateTime
Declare @ToDate as DateTime

set @GLCode = (SELECT T0.[AcctCode] FROM OACT T0 WHERE T0.[FormatCode] = '[%0]' and T0.GroupMask=6)
set @FromDate = (SELECT min(T1.RefDate)FROM JDT1 T1 WHERE T1.RefDate = '[%1]')
Set @ToDate = (SELECT min(T2.RefDate)FROM JDT1 T2 WHERE T2.RefDate = '[%2]')


SELECT T3.[RefDate] as 'Posting Date', T3.[TransId] as 'Origin', T4.[AcctName] as 'Acct. Name', T3.[LineMemo] as 'Details', T3.[Debit] as 'Debit Amount', T3.[Credit] as 'Credit Amount'
FROM JDT1 T3  INNER JOIN OACT T4 ON T3.Account = T4.AcctCode 

WHERE T3.[Account] = @GLCode and T3.RefDate >= @FromDate and T3.RefDate <= @ToDate

ORDER BY T3.[RefDate]

this query does not return any value in SBO.

What do you think is wrong???

Please advice

Thanks.

FIDEL

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 13, 2010 at 05:44 AM

    Hello Fidel,

    I don't think you need parameter for this. Try:

    SELECT T3.[RefDate] as 'Posting Date', T3.[TransId] as 'Origin', T4.[AcctName] as 'Acct. Name', 
    T3.[LineMemo] as 'Details', T3.[Debit] as 'Debit Amount', T3.[Credit] as 'Credit Amount'
    
    FROM JDT1 T3  
    INNER JOIN OACT T4 ON T3.Account = T4.AcctCode 
     
    WHERE T4.[AcctName] = '[%0]' and T3.RefDate Between [%1] AND [%2]
     

    Thanks,

    Gordon

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.