我收到消息102,级别15,状态1,过程PROC_GMAPSDATA,行15'''附近的语法不正确

时间:2015-11-24 09:36:57

标签: sql-server

我收到错误

  

Msg 102,Level 15,State 1,Procedure PROC_GMAPSDATA,Line 15
  ')'

附近的语法不正确

我的代码在这里:

CREATE PROCEDURE PROC_GMAPSDATA
    (@DEVICENUMBER INT)
AS
BEGIN
    DECLARE @DEVICEID INT

    SET @DEVICEID = (SELECT DEVICEID 
                     FROM DEVICEMASTER 
                     WHERE DEVICENO = @DEVICENUMBER)

    SELECT 
        REGISTRATIONNUMBER AS TRUCKNUMBER,
        CURRENTLOCATION AS CURRENTLOCATION, 
        CURRENTLATLNG AS CURRENTLATLNG 
    FROM 
        TRUCKMASTER 
    WHERE 
        DeviceID IN (SELECT DEVICEID 
                     FROM DEVICEMASTER 
                     WHERE DEVICENO = @DEVICENUMBER) 
GO

1 个答案:

答案 0 :(得分:1)

我在您的存储过程中添加了以下更改。  一个)。已添加END个关键字。  B)。使用值赋值变量@DEVICEID  C)。格式化更改。

 CREATE PROCEDURE [dbo].PROC_GMAPSDATA
 (
 @DEVICENUMBER INT
 )
 AS
  BEGIN
      SET NOCOUNT ON;
      DECLARE @DEVICEID INT;

      SET @DEVICEID =(
                      SELECT 
                      DEVICEID 
                      FROM [dbo].[DEVICEMASTER] 
                      WHERE DEVICENO = @DEVICENUMBER
                      )

      SELECT REGISTRATIONNUMBER AS TRUCKNUMBER,
             CURRENTLOCATION    AS CURRENTLOCATION, 
             CURRENTLATLNG      AS CURRENTLATLNG 
      FROM [dbo].[TRUCKMASTER] 
      WHERE DeviceID = @DEVICEID

      SET NOCOUNT OFF;
   END
 GO