jston
jston

Reputation: 21

Incorrect syntax near the keyword 'UPDATE'

Have the following procedure and get syntax error at Update:

USE [OTIDatabaseNewOutreach_V3.2.0_BESQL]
GO
/****** Object:  StoredProcedure [dbo].[usp_OTIDataImportConstruction_U]    Script Date: 5/12/2016 8:44:18 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[usp_OTIDataImportConstruction_U]

    UPDATE dbo.[OTI Trainer Data Import]  
    SET [Construction Industry Card #] = IsNull([c_cardnumberissued],[TrainerIDNumber]),
        [Construction Date Issued] = [tblCourse].[c_enddate]
    from tblCourse
    inner JOIN dbo.tblCourseToStudent ON dbo.tblCourse.c_id = dbo.tblCourseToStudent.c_id 
    INNER JOIN
            dbo.[OTI Trainer Data Import] ON dbo.tblCourseToStudent.t_id = dbo.[OTI Trainer Data Import].t_id
    WHERE (c_program ='construction') AND (c_expdate>GetDate());

go      

...................................................................... .

Upvotes: 2

Views: 3593

Answers (2)

Phil
Phil

Reputation: 4069

USE [OTIDatabaseNewOutreach_V3.2.0_BESQL] GO /****** Object: StoredProcedure [dbo].[usp_OTIDataImportConstruction_U] Script Date: 5/12/2016 8:44:18 AM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO

CREATE PROCEDURE [dbo].[usp_OTIDataImportConstruction_U] 
AS
BEGIN

UPDATE dbo.[OTI Trainer Data Import]  
    SET [Construction Industry Card #] = IsNull([c_cardnumberissued],[TrainerIDNumber]),
        [Construction Date Issued] = [tblCourse].[c_enddate]
    from tblCourse
        inner JOIN dbo.tblCourseToStudent ON dbo.tblCourse.c_id = dbo.tblCourseToStudent.c_id INNER JOIN
            dbo.[OTI Trainer Data Import] ON dbo.tblCourseToStudent.t_id = dbo.[OTI Trainer Data Import].t_id
    WHERE (c_program ='construction') AND (c_expdate>GetDate());

END
GO

Upvotes: 1

Sean
Sean

Reputation: 1474

Looks like SQL Server. You need an as after the create procedure. See the manual: https://msdn.microsoft.com/en-za/library/ms187926.aspx

Upvotes: 4

Related Questions