Hi, I have table1 and table2 and i want to fill information from table1 into table2 using a stored procedure. Here's what i have:
create sp_table2
(@personId varchar(36),
@value varchar(40) OUTPUT
@value1 varchar(40) OUTPUT)
as
begin
insert into table2 (date, first_name, last_name, personId, value, value1)
select date, first_name, last_name, @personId,
@value = CASE item
WHEN 'food' Then '3' END,
@value1 = CASE item
WHEN 'drink' THEN '2' END
from table1
end
However, i keep getting this error message below. Can someone help? Thanks
Error message:
A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.
create sp_table2
(@personId varchar(36),
@value varchar(40) OUTPUT
@value1 varchar(40) OUTPUT)
as
begin
insert into table2 (date, first_name, last_name, personId, value, value1)
select date, first_name, last_name, @personId,
@value = CASE item
WHEN 'food' Then '3' END,
@value1 = CASE item
WHEN 'drink' THEN '2' END
from table1
end
However, i keep getting this error message below. Can someone help? Thanks
Error message:
A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.