CREATE PROCEDURE [dbo].[sp_insertStudent](@name char(10),@age int,@id int OUTPUT) AS insert into Students([Name],[Age]) values (@name,@age) select @id=@@IDENTITY GO
int id = pstmt.getInt(3); System.out.println(id); } 使用返回参数的例子:
CREATE PROCEDURE [dbo].[sp_insertStudent](@name char(10),@age int,@id int OUTPUT) AS insert into Students([Name],[Age]) values (@name,@age) select @id=@@IDENTITY –测试输出参数 return 30 –测试返回30 GO