DECLARE @ThisCompDate AS datetime, @Fiscal_cd int, @DateString as varchar(50) SET @ThisCompDate = GETDATE() SET @DateString = CAST(DATEPART(m,@ThisCompDate) AS varchar(2)) + '/' + CAST(DATEPART(d,@ThisCompDate) AS varchar(2)) + '/' + CAST(DATEPART(yyyy,@ThisCompDate) AS varchar(4)) SET @ThisCompDate = CAST(@DateString AS datetime) DECLARE @LastCompDate AS datetime SET @LastCompDate = ( SELECT DT FROM MFI_SYS WHERE SYS_CD = 'LAST_COMP_DATE' ) select @Fiscal_cd = fiscal_cd from mfi_fiscal_calendar where date = @ThisCompDate if @Fiscal_cd = 201109 begin update mfi_comp set unitssold = 0, [returns] = 0 where store_cd in ('QY','QX','QU','TX') and fiscal_cd = @Fiscal_cd and check_cut = 'N' end --Flat Rate by Market update dbo.mfi_comp set Comm = (case SLSP_TP_CD when 'POD' then comp_ret_prc * .02 else comp_gross * FlatCommissionRate end), Comm_rate = (case SLSP_TP_CD when 'POD' then .02 else FlatCommissionRate end), Prem = 0, Prem_Rate = 0, Unitssold = (case isSSS when 0 then 0 else Unitssold end), [Returns] = (case isSSS when 0 then 0 else [Returns] end) from dbo.MFI_MARKET_COMMISSION as M, dbo.vGERS_EMP_SLSP as E where E.EMP_CD = dbo.mfi_comp.EMP_CD and M.Market = dbo.mfi_comp.Market and M.isFlatCommission = 1 and dbo.mfi_comp.Fiscal_cd >= @FISCAL_CD and dbo.mfi_comp.CHECK_CUT = 'N' and dbo.mfi_comp.CLR = 'N' --Flat Rate by Store update dbo.mfi_comp set Comm = (case SLSP_TP_CD when 'POD' then comp_ret_prc * .02 else comp_ret_prc * FlatCommissionRate end), Comm_rate = (case SLSP_TP_CD when 'POD' then .02 else FlatCommissionRate end), Prem = 0, Prem_Rate = 0, Unitssold = (case isSSS when 0 then 0 else Unitssold end), [Returns] = (case isSSS when 0 then 0 else [Returns] end) from dbo.MFI_STORE_COMMISSION as M, dbo.vGERS_EMP_SLSP as E where E.EMP_CD = dbo.mfi_comp.EMP_CD and M.GersCode = dbo.mfi_comp.STORE_CD and M.isFlatCommission = 1 and dbo.mfi_comp.Fiscal_cd >= @FISCAL_CD and dbo.mfi_comp.CHECK_CUT = 'N' and ((isCLRTicketOnly = 1 and dbo.mfi_comp.CLR = 'Y') or isCLRTicketOnly = 0) print 'CompProcessSSSRows ' EXEC CompProcessSSSRows @ThisCompDate update MFI_Comp set COMM = COMP_RET_PRC * .08, PREM = 0.00, COMM_RATE = .08, PREM_RATE = 0.00 where CLR = 'Y' and CHECK_CUT = 'N' and STORE_CD in (select code from MattressGiantStore)
Can anyone help me with the above code.. its a Sql job which is failing and i am getting an error..
Message
Executed as user: MFIGERSRDS01\SYSTEM. ...t:
DTSStep_DTSExecuteSQLTask_2 DTSRun OnFinish:
DTSStep_DTSExecuteSQLTask_2 DTSRun OnStart:
DTSStep_DTSExecuteSQLTask_1 DTSRun OnError:
DTSStep_DTSExecuteSQLTask_1, Error = -2147467259
(80004005) Error string: Subquery returned
more than 1 value. This is not permitted when the subquery follows =, !=, <,
<= , >, >= or when the subquery is used as an
expression. Error source: Microsoft OLE DB
Provider for SQL Server Help
file: Help context:
0 Error Detail
Records: Error: -2147467259 (80004005);
Provider Error: 512 (200) Error
string: Subquery
returned more than 1 value. This is not permitted when the subquery follows =,
!=, <, <= , >, >= or when the subquery is used as an expression.
Error source: Microsoft OLE DB Provider for SQL
Server Help
file: Help context:
0 Error: 0 (0); Provider
Error: 0 (0) Error string: going to
the cursor E... Process Exit Code 1.
The step failed.
FM