SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Incorrect Syntax Near ' '.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Villanuev
Constraint Violating Yak Guru

311 Posts

Posted - 06/05/2012 :  03:22:39  Show Profile  Reply with Quote
Guys,

Kindly please help me to identify this error appears when im running this script. i will show you some parts of the scripts.

Error:

Msg 102, Level 15, State 1, Line 10
Incorrect syntax near ' '.
Msg 102, Level 15, State 1, Line 24
Incorrect syntax near ' '.
Msg 102, Level 15, State 1, Line 27
Incorrect syntax near ' '.
Msg 102, Level 15, State 1, Line 31
Incorrect syntax near ' '.
Msg 102, Level 15, State 1, Line 46
Incorrect syntax near ' '.
Msg 102, Level 15, State 1, Line 75
Incorrect syntax near 'ivt'.
Msg 102, Level 15, State 1, Line 90
Incorrect syntax near ' '.

Scripts:
SELECT
					consupmtionTable.Asuprodlined
					,consupmtionTable.itemid
					,consupmtionTable.partNo
					,finishedfone = coalesce(finphones.finishedfone,0) 
					,it.itemname
					,coalesce(
					(
					CASE WHEN EXISTS 
					(select itemgroupid from dbo.inventitemgroup where dataareaid='tmp' and itemgroupid = it.itemgroupid and  asuCore = 1) 
					THEN 1 ELSE CAST(bomTable.requiredQty AS NUMERIC
					) END
					* finphones.finishedfone),0
					) AS REQUIREDQTY
					 ,SUM(consupmtionTable.NEWCOST) AS NEWPARTAVGCOST
					 ,SUM(consupmtionTable.REFURBCOST) AS REFURBPARTAVGCOST
					 ,CAST(SUM(consupmtionTable.NEWQTY) AS NUMERIC) AS NEWPARTSQTY
					 ,CAST(SUM(consupmtionTable.RECLAIMQTY) AS NUMERIC) AS RECLAIMQTY
					 ,CAST(SUM(consupmtionTable.REFURBQTY) AS NUMERIC) AS REFURBQTY
					 ,CAST(SUM(consupmtionTable.NEWQTY) + SUM(consupmtionTable.RECLAIMQTY)+ SUM(consupmtionTable.REFURBQTY) AS NUMERIC) AS TOTAL
	            FROM
	            (
	                  select x.requiredPart,x.itemid,sum(x.requiredQty) as requiredQty
	                  from
	                  (
	                        select prodlist.itemid,bomlist.partQty as requiredQty, bomlist.partId as requiredPart from
	                        (
								select distinct pt.Itemid
								from #Prod pt
								group by pt.Itemid
	                        ) prodList
	                        left outer join
	                        (
								select bv.itemid as phoneId,
									bom.bomqty as partQty, 
									bom.itemid as partId 
								from 
									dbo.bomversion bv
								inner join 
									dbo.bom on bom.dataareaid = bv.dataareaid and bom.bomid = bv.bomid 
								where 
								bv.dataareaid='tmp'
								and bom.dataareaid='tmp'
								AND bv.name = 'Normal'
								and bom.bomqty > 0
	                        )bomList on bomList.phoneId = prodList.itemid
	                  )x group by x.itemid,x.requiredPart
	            ) bomTable


what are the cause of these error.

Thank you in advnce

jov

webfred
Flowing Fount of Yak Knowledge

Germany
8515 Posts

Posted - 06/05/2012 :  03:35:49  Show Profile  Visit webfred's Homepage  Reply with Quote
The first cast is missing ) at the end


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3328 Posts

Posted - 06/05/2012 :  05:51:36  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
Think it's on the next line before the END.
Are you sure there aren't some odd characters that look like white spaces?

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Villanuev
Constraint Violating Yak Guru

311 Posts

Posted - 06/05/2012 :  21:34:49  Show Profile  Reply with Quote
Thank you guys for the reply. It's Working.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000