Sql server Stored Procedure
- by user177883
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?