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,);
私はSQLServerであなたができることを知っています:
INSERT INTO MyTable .... SELECT @Foo = @@IDENTITY INSERT INTO SomeOtherTable(... fk_col ...) VALUES (... @foo ...)