2

我正在更改存储过程,当我尝试执行时,我得到:

Msg 156, Level 15, State 1, Procedure vtg_asmbltimephasedashassy, Line 20  
Incorrect syntax near the keyword 'AS'   

但是当我转到第20行时,没有关键字'as',也没有直接在第20行之前或之后的行中。也许我数错了。

当我数到第 20 行时,我得到的行是

jobmtl.partnum=partwhse.partnum FULL OUTER JOIN  

谁能指出我正确的方向,因为我需要做些什么来解决这个问题?我的整个存储过程如下。

USE [mfgsys803]
GO
/****** Object:  StoredProcedure [dbo].[vtg_asmbltimephasedashassy]    Script Date:   01/08/2013 12:59:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER proc [dbo].[vtg_asmbltimephasedashassy] @p_plant varchar(max) 
as 
begin 
set nocount on;

SELECT     jobhead.jobnum, sum(partwhse.onhandqty) as 'onhandqty', jobhead.partnum, jobhead.revisionnum, jobhead.prodqty, jobhead.startdate, jobhead.duedate, jobhead.reqduedate, 
                  jobhead.commenttext, jobmtl.issuedcomplete, jobmtl.issuedqty, jobmtl.mtlseq, jobmtl.partnum AS 'mtlpart', jobmtl.requiredqty, jobmtl.qtyper, jobmtl.reqdate, 
                  partwhse.warehousecode, prodgrup.description
FROM         jobmtl LEFT OUTER JOIN
                  partwhse INNER JOIN
                  warehse ON partwhse.company = warehse.company AND partwhse.warehousecode = warehse.warehousecode ON jobmtl.company = partwhse.company AND 
                  jobmtl.partnum = partwhse.partnum FULL OUTER JOIN
                  prodgrup INNER JOIN
                  jobhead ON prodgrup.company = jobhead.company AND prodgrup.prodcode = jobhead.prodcode ON jobmtl.company = jobhead.company AND 
                  jobmtl.jobnum = jobhead.jobnum
WHERE     (jobhead.jobreleased = 0) AND (jobhead.jobfirm = 1) AND (jobhead.jobengineered = 1) AND (jobhead.company = 'lot') and  (prodgrup.description like '%assy%') and (jobhead.plant=@p_plant) and (warehse.plant=@p_plant)

group by     jobhead.jobnum, jobhead.partnum, jobhead.revisionnum, jobhead.prodqty, jobhead.startdate, jobhead.duedate, jobhead.reqduedate, 
                  jobhead.commenttext, jobmtl.issuedcomplete, jobmtl.issuedqty, jobmtl.mtlseq, jobmtl.partnum AS 'mtlpart', jobmtl.requiredqty, jobmtl.qtyper, jobmtl.reqdate, 
                  partwhse.warehousecode, prodgrup.description


end 
4

2 回答 2

3

将这部分从组中取出

jobmtl.partnum AS 'mtlpart'

做了

jobmtl.partnum 
于 2013-01-08T19:35:08.967 回答
0

行号只是指包含错误的 SQL 语句的行号......这是整个 Select 语句。As 在 Group By 中jobmtl.partnum AS 'mtlpart',并且需要出来。

于 2013-01-08T19:35:53.270 回答