Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在编写批量加载 SQL 脚本,我想将生成的插入语句的主键存储到临时变量中,并使用它来引用其他表中的外键。有任何想法吗?
我正在执行以下操作:
Y = INSERT INTO X(.....) INSERT INTO Z(...,Y,);
我知道在 SQL Server 中你可以这样做:
INSERT INTO MyTable .... SELECT @Foo = @@IDENTITY INSERT INTO SomeOtherTable(... fk_col ...) VALUES (... @foo ...)