I'm working on trigger in MSSQL and i got this error message:
Msg 512, Level 16, State 1, Procedure TirregerUpdate, Line 11 [Batch Start Line 0]
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. The statement has been terminated.
Also these are my sql codes:
Declare @NAME varchar(255) = 'ONE';
Declare @MKOD varchar(255);
Declare @OMKOD varchar(255);
DECLARE @STATUS BIT = 0;
IF @STATUS = 1
BEGIN
SET @MKOD = CASE @NAME
WHEN 'ONE' THEN '1'
WHEN 'TWO' THEN '2'
WHEN 'TRHEE' THEN '3'
END
SET @OMKOD = CASE @NAME
WHEN 'ONE' THEN '1 - ONE'
WHEN 'TWO' THEN '2 - TWO'
WHEN 'TRHEE' THEN '3 - TRHEE'
END
END
ELSE
BEGIN
SET @MKOD = CASE @NAME
WHEN 'ONE' THEN '1 - ONE'
WHEN 'TWO' THEN '2 - TWO'
WHEN 'TRHEE' THEN '3 - TRHEE'
END
SET @OMKOD = CASE @NAME
WHEN 'ONE' THEN '1'
WHEN 'TWO' THEN '2'
WHEN 'TRHEE' THEN '3'
END
END
UPDATE PRODUCT SET MKOD = @MKOD WHERE MKOD = @OMKOD;
Can you help me solving this situations. Thank you..