0

我设法从table_sourceinto克隆了一行table_temp,并更新了它的字段f0

但是我怎样才能指向新插入的行呢?

我想将新插入的 id 从表中插入table_source到以下字段f_idtable2

INSERT into table_temp (f0, f1, f2)  
  select f0, f1, f2 from table_source   
  where . . .

UPDATE table_temp SET f0 =  'newValue'  

INSERT INTO table_source select * from table_temp  

UPDATE table2 SET f_id = ??? WHERE . . .      <- what id can I use here?

DELETE FROM table_temp 
4

1 回答 1

1

Scope_Identity()返回当前范围内最后插入的行的标识符。另请参阅@@identity

于 2013-11-10T10:59:49.163 回答