我将一个变量传递给存储过程,我希望proc查看另一个表并获取表的主键并将该值插入表中。Sql server存储过程
Table A:
pk_id int,
user varchar
Table B:
userKey int
locationKey int
Someotherthings varchar
Table C:
pk_id int,
Location varchar
当调用sp_howto,并通过用户给它,我想它得到表A中pk_id并将其插入到表B中USERKEY。
set @res = select pk_id from TableA where [email protected]
set @loc = select pk_id from TableC where location = @Location
insert into tableB (userKey, locationKey) values (@res, @loc)
工作的呢?和如果我有很多变量我想要这样填充?
目前尚不清楚你所说的“很多关键点”的意思是什么你的意思是你想为许多对表做这个? – egrunin 2010-04-05 19:40:44
我编辑了这个问题。 – DarthVader 2010-04-05 19:49:42
我编辑了我的答案。 – egrunin 2010-04-05 21:56:33