Stored procedure for add and update record

Santosh0683
Posted by Santosh0683 under Sql Server category on | Views : 3732
Here i have written a simple stored procedure that we need to many places in our application

CREATE PROCEDURE usp_UniversityAddUpdate
(
@UniversityId int,
@University varchar(50),
@CreatedBy int,
@CreatedOn datetime,
)
AS
BEGIN
IF @UniversityId=0
BEGIN
IF NOT EXISTS(SELECT * FROM tblUniversity WHERE University= @University)
INSERT INTO tblUniversity(University, CreatedBy, CreatedOn)
VALUES(@University,@CreatedBy,@CreatedOn)
END
ELSE
BEGIN
UPDATE tblUniversity
SET University = @University
WHERE(UniversityId = @UniversityId)
END
END

Comments or Responses

Login to post response