Getting an automatic serialNumber from the database
In my project, I have to get a StudentId when the data is saved for the
first time(technically INSERT command) from the database. Currently my
stored proc for insertion is as follows:
ALTER PROCEDURE [dbo].[usp_iSaveStudent]
-- Add the parameters for the stored procedure here
@StudentId varchar(50),
@FirstName varchar(50),
@MiddleName varchar(50),
@LastName varchar(50),
@CGPA decimal(18),
@Email varchar(50)
AS
BEGIN
insert into dbo.Student
values(@StudentId,@FirstName,@MiddleName,@LastName,@CGPA,@Email)
END
I am passing NULL string for studentId while saving for the first time.
Could anyone please suggest me how to generate an automatically
incremented StudentId for each record I insert and simultaneously return
that to my program ?
Thanks in advance.
No comments:
Post a Comment