You need to assign the value to @userid
! Also, I would recommend using SCOPE_IDENTITY()
and not @@IDENTITY
:
CREATE PROCEDURE Users_Insert
-- Add the parameters for the stored procedure here
@userid int output,
@name varchar(50),
@surname varchar(50),
@email varchar(200),
@password varchar(50),
@location varchar(50)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
insert into Users(FirstName, LastName, Email, Password, Location)
values(@name, @surname, @email, @password, @location);
-- make an actual **assignment** here...
SELECT @userid = SCOPE_IDENTITY();
END
See this blog post for an explanation as to WHY you should use SCOPE_IDENTITY
over @@IDENTITY