Click here to Skip to main content
16,020,673 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is an SP,when i execute in SMStudio it getting error
Msg 102, Level 15, State 1, Line 7
Incorrect syntax near ')'.



DECLARE @tblPossibleAudits TABLE (auditid int)

SELECT DISTINCT TBL.auditid, AD.auditname
FROM (
SELECT POS.auditid, COUNT(AJ.loanmasterid) as totalloans, COUNT(IMG.loanmasterid) as imgloadedloans
FROM @tblPossibleAudits POS INNER JOIN auditjunction AJ
ON AJ.auditid = POS.auditid LEFT JOIN ldocumentimages IMG)
ON IMG.loanmasterid = AJ.loanmasterid
GROUP BY POS.auditid
)
TBL INNER JOIN auditdescriptions AD
ON AD.auditid = TBL.auditid
WHERE TBL.totalloans > TBL.imgloadedloans
ORDER BY AD.auditname
FOR XML AUTO
Posted

Try this:
SQL
SELECT DISTINCT TBL.auditid
			  , AD.auditname
FROM
	(SELECT POS.auditid
		  , count(AJ.loanmasterid) AS totalloans
		  , count(IMG.loanmasterid) AS imgloadedloans
	 FROM
		 @tblPossibleAudits POS
		 INNER JOIN auditjunction AJ
			 ON AJ.auditid = POS.auditid
		 LEFT JOIN ldocumentimages IMG
			 ON IMG.loanmasterid = AJ.loanmasterid
	 GROUP BY
		 POS.auditid
	)
	TBL
	INNER JOIN auditdescriptions AD
		ON AD.auditid = TBL.auditid
WHERE
	TBL.totalloans > TBL.imgloadedloans
ORDER BY
	AD.auditname
FOR XML
	AUTO
 
Share this answer
 
Hi,

i guess there is an extra ) after IMG.Try removing that.
 
Share this answer
 
ON AJ.auditid = POS.auditid LEFT JOIN ldocumentimages IMG)

remove ) from this line...

Thanks,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900