ALTER PROCEDURE [dbo].[Insert_Update_Students]( @SelectedCourse varchar(4000) = NULL ,@StudentID int = NULL output ,@UserID int = NULL ,@YogaBefore bit = NULL ,@YourComment varchar(250) = NULL ) AS BEGIN SET NOCOUNT ON; IF(@StudentID IS NULL OR @StudentID <= 0) BEGIN INSERT INTO Students( [SelectedCourse] ,[UserID] ,[YogaBefore] ,[YourComment] ) VALUES( @SelectedCourse ,@UserID ,@YogaBefore ,@YourComment ) set @StudentID=@@identity; END ELSE BEGIN UPDATE Students SET[SelectedCourse]=@SelectedCourse ,[UserID]=@UserID ,[YogaBefore]=@YogaBefore ,[YourComment]=@YourComment where [StudentID]=@StudentID END END