Quantcast
Channel: CSharp Forum Latest Questions
Viewing all articles
Browse latest Browse all 32029

SQL

$
0
0
I am getting an error "The multi-part identifier "tblChitReg.iRegId" could not be bound."


declare @iRegId int
set @iRegId ='17'
declare @TrDate datetime
set @TrDate ='11/11/2012'
-- SELECT iRegId FROM tblChitReg WHERE vExecutive='RAJU'
SELECT     InstNo, InstDate, InstAmount
    FROM         (SELECT     Cim.iInstNo AS InstNo, CASE WHEN vIntervalType = 'Days' THEN dateadd(D, (Cim.iInstNo - 1) * Cs.iInterval, Cr.dStartDate)
                                                  WHEN vIntervalType = 'Months' THEN dateadd(M, ((Cim.iInstNo - 1) * Cs.iInterval), Cr.dStartDate) ELSE dateadd(Y, ((Cim.iInstNo - 1)
                                                  * Cs.iInterval), Cr.dStartDate) END AS InstDate, Cid.fInstAmount AS InstAmount
                           FROM          tblChitReg AS Cr INNER JOIN
                                                  tblChitMaster AS Cs ON Cs.iChitId = Cr.iChitId LEFT OUTER JOIN
                                                  tblChitAuctionMaster AS Cam ON Cr.iRegId = Cam.iRegId AND Cam.cCancel = 'N' INNER JOIN
                                                  tblChitInstMaster AS Cim ON Cim.iChitId = Cr.iChitId AND Cim.cCancel = 'N' INNER JOIN
                                                  tblChitInstDetails AS Cid ON Cim.iInstId = Cid.iInstId AND Cid.iNoOfFractions = Cr.fNoOfFractions AND
                                                  Cid.cCustType = CASE WHEN isnull(Cam.iRegId, 0) > 0 THEN 'A' ELSE 'N' END
                           WHERE      (Cr.iRegId =@iRegId ) AND (Cim.iInstNo > ISNULL
                                                      ((SELECT     MAX(iInstNo) AS Expr1
                                                          FROM         tblChitReceipts
                                                          WHERE     (iRegId = @iRegId) AND (dTrDt <= dateadd(D,1,@TrDate))), 0))) AS R
    WHERE     (InstDate <= @TrDate) and tblChitReg.iRegId =(SELECT iRegId FROM tblChitReg WHERE vExecutive='RAJU')

Viewing all articles
Browse latest Browse all 32029

Trending Articles