SQL Server - 插入後的返回值 - SQL Server - Return value after INSERT

問題:

I'm trying to get a the key-value back after an INSERT-statement.我試圖在 INSERT 語句後取回鍵值。 Example: I've got a table with the attributes name and id.示例:我有一個帶有屬性名稱和 ID 的表。 id is a generated value. id 是生成的值。

    INSERT INTO table (name) VALUES('bob');

Now I want to get the id back in the same step.現在我想在同一步驟中取回 id。 How is this done?這是怎麼做的?

We're using Microsoft SQL Server 2008.我們使用的是 Microsoft SQL Server 2008。


解決方案:

參考一: https://en.stackoom.com/question/XDkl
參考二: https://stackoom.com/question/XDkl
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章