我要将数据插入到表中,如下所示:
Insert Into MyTable (Field1, Field2)
Values ('test', 5)
Run Code Online (Sandbox Code Playgroud)
发生插入时,新行将在ID列中具有标识值.如果@ID在我的T-SQL代码中调用了一个变量,如何填充@IDT-SQL插入的结果?
Declare @ID int
Insert into MyTable (Field1, Field2)
Values ('test', 5)
--//How do I populate @ID with the value of ID of the record that was just inserted?
Run Code Online (Sandbox Code Playgroud)