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
locationKey int
Someotherthings varchar
Table C:
pk_id int,
Location varchar
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.
set @res = select pk_id from TableA where user=@user
set @loc = select pk_id from TableC where location = @Location
insert into tableB (userKey, locationKey) values (@res, @loc)
Does this work? and what if I have many variables I want to populate like this?