BDG Scenario 3

lw_changeActivityType.sql

If Exists (Select * From sysobjects Where name = N'lw_changeActivityType' And user_name(uid) = N'dbo')
    Drop Procedure dbo.lw_changeActivityType
Go

Create Procedure lw_changeActivityType(
 @activityTypeId int,
 @gradeScaleId int,
 @name nvarchar(20),
 @description nvarchar(50),
 @weight tinyint,
 @dropLowest tinyint,
 @lateType tinyint,
 @lateValue tinyint
 )
As
 set nocount on 
 
 if exists(select * from activityType where activityTypeId = @activityTypeid)
 
  begin
   update activityType set gradeScaleId = @gradeScaleId,[name]=@name,
      description = @description, weight= @weight,dropLowest = @dropLowest,
        lateType = @lateType, lateValue = @lateValue
        where activityTypeid = @activityTypeid      
   return 0
  end
 
 else
 
  begin
   raiserror('activityType with %ld ID does not exist.',-1,-1,@activityTypeId) with nowait
   return 1
  end
 
 

Go