1
使用SCOPE_IDENTITY()時,我想執行一個SQL查詢將返回已添加到錶行的當前身份ID:一致性輸出
DECLARE @id int
DECLARE @tblOutput table (id int)
INSERT INTO tblStudent(Name, Family, age, test)
OUTPUT inserted.id into @tblOutput
VALUES('ashghar', 'farhadi', 321, 135)
SELECT @id = id from @tblOutput
現在我的問題是它返回的ID對於我當前插入的行或者它是最後插入的行的ID?
我的意思是我可以相信它用作外鍵嗎?