返回INSERT 的ID值
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
CREATE TABLE [Role] (
[RoleID] [int] IDENTITY (1, 1) PRIMARY KEY CLUSTERED ,
[CategoryID] [int],
[RoleName] [nvarchar] (10) NULL DEFAULT (''),
[Descriptio] [nvarchar] (50) NULL)
)
返回INSERT 的ID值
CREATE PROCEDURE sp_Role_Add
@CategoryID int,
@RoleName nvarchar(10),
@Description nvarchar(50),
@RoleID int output
AS
INSERT INTO Role (CategoryID, RoleName, Description) valueS (@CategoryID, @RoleName, @Description)
SET @RoleID = @@IDENTITY
RETURN 1
GO
下面是一个之前程序用过的prodecure, 里面包括传入、传出的参数设置。
/**//****** Object: Stored Procedure dbo.pro_CheckAdminLogin Script Date: 2004-6-4 16:37:25 ******/
CREATE PROCEDURE pro_CheckAdminLogin
(
@username nvarchar(20),
@password char(32),
@lastloginip char(15),
@output int output
)
AS
if exists(Select id from admin where username=@username and password=@password)
begin
update admin set lastLoginIP=@lastloginip,lastlogintime=getdate() where username=@username
set @output=0 --验证通过
end
else
begin
set @output=-1 --帐号密码不正确
end
GO