SQL Server Create a stored procedure but getting this message

ogq8wdun  于 2023-02-28  发布在  其他
关注(0)|答案(1)|浏览(166)

This procedure will update data in column but ended up with this message
Msg 4145, Level 15, State 1, Procedure updatetings , Line 26 [Batch Start Line 4] An expression of non-boolean type specified in a context where a condition is expected, near 'BEGIN'.

This bold words is the problem come from

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE updatetings
    @i_id VARCHAR (50),
    @i_proccess VARCHAR (10),
    @i_line VARCHAR (50),
    @i_group VARCHAR (10),
    @i_date DATETIME

WITH EXEC AS CALLER
AS
BEGIN
    
   SET NOCOUNT ON
   SET  NUMERIC_ROUNDABORT OFF
   SET  ANSI_NULLS , ANSI_PADDING , ANSI_WARNINGS , ARITHABORT ,
   CONCAT_NULL_YIELDS_NULL , QUOTED_IDENTIFIER ON

    -- PROBLEM HERE 
    IF @i_proccess = 'xxx' 
    BEGIN
        UPDATE database SET
            date = @i_date,line = @i_line,Group = @i_group
        WHERE id = @i_id 
    END

END

EXEC updatetings '8','xx','xx','xx','2022-02-23 08:25:43.780'
c2e8gylq

c2e8gylq1#

some answer is needed for when the IF does not have the result you expect

BEGIN UPDATE database SET date = @i_date,line = @i_line,Group = @i_group WHERE id = @i_id END ELSE BEGIN PRINT 'Nothing to update' END

相关问题