Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Incorrect Syntax Near ' '.

Author  Topic 

Villanuev
Constraint Violating Yak Guru

478 Posts

Posted - 2012-06-05 : 03:22:39
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
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-06-05 : 03:35:49
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
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-06-05 : 05:51:36
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

478 Posts

Posted - 2012-06-05 : 21:34:49
Thank you guys for the reply. It's Working.
Go to Top of Page
   

- Advertisement -