Sql server Stored Procedure
Posted
by user177883
on Stack Overflow
See other posts from Stack Overflow
or by user177883
Published on 2010-04-05T18:58:54Z
Indexed on
2010/04/05
19:03 UTC
Read the original article
Hit count: 137
I m passing a variable to stored procedure, i want the proc to make a look up to another table and get the primary key of the table and insert that value to the table.
Table A:
pk_id int,
user varchar
Table B:
userKey int
When i invoke sp_howto, and pass user to it, i want to it to get the pk_id from table A and insert it to table B userKey.
@res = select userKey from TableA where user=@user
insert into tableB (userKey) values (@res)
Does this work? and what if I have many keys I want to populate like this?
© Stack Overflow or respective owner