Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored Procedure to insert into another table

Status
Not open for further replies.

sinCity99

Programmer
Jan 21, 2009
20
US
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top