I need a function which executes an INSERT statement on a database and returns the Auto_Increment primary key. I have the following C# code but, while the INSERT statement w
CREATE procedure dbo.sp_whlogin
(
@id nvarchar(20),
@ps nvarchar(20),
@curdate datetime,
@expdate datetime
)
AS
BEGIN
DECLARE @role nvarchar(20)
DECLARE @menu varchar(255)
DECLARE @loginid int
SELECT @role = RoleID
FROM dbo.TblUsers
WHERE UserID = @id AND UserPass = @ps
if @role is not null
BEGIN
INSERT INTO TblLoginLog (UserID, LoginAt, ExpireAt, IsLogin) VALUES (@id, @curdate, @expdate, 1);
SELECT @loginid = @@IDENTITY;
SELECT @loginid as loginid, RoleName as role, RoleMenu as menu FROM TblUserRoles WHERE RoleName = @role
END
else
BEGIN
SELECT '' as role, '' as menu
END
END
GO