Skip to Content
0
Former Member
Jun 14, 2011 at 09:28 AM

Error in Query generator

334 Views

Dear all,

I face an issue in Query generator.

When i execute the query in query generator, the error is like this

1). [Microsoft][SQL Server Native Client 10.0][SQL Server]Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

'Service Contracts' (OCTR)

My query is like this

Declare @StartYear as char(4)
Declare @EndYear as char(4)
Declare @Dept as char(3)
Declare @UnitBusiness as char(3)

Begin

set @StartYear = (Select   YEAR(T0.[RefDate]) from JDT1 T0 where T0.[RefDate] = [%0] )
set @EndYear =  (Select YEAR(T1.[RefDate]) from JDT1 T1 where T1.[RefDate] = [%1])
set @Dept =  (Select T2.[Name] from OASC T2 where T2.[Name] = [%2])


set @UnitBusiness = (Select   distinct SUBSTRING(T3.[Segment_0],10,2)  from OACT T3 where ( T3.[Segment_0] = [%3] OR ( 1 = (CASE WHEN [%3]  = 'All'  THEN 1 ELSE 2 END) ) ))

Exec NEC_RPT_FinanceReport @StartYear,@EndYear,@Dept,@UnitBusiness
End

The problem is i can not show the input screen after i execute the query generator.

If i remove the the Variable @Dept and replace with the value it runs well.

Does any one know where is the problem ?

Thanks in advance

Regards

Bodhi86