BDG Scenario 3

lw_changeGroup.sql

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

CREATE  Procedure lw_changeGroup(
      @groupId int,
  @locationId int,
  @name nvarchar(20),
  @description nvarchar(50),
  @beginDate datetime,
  @endDate datetime,
  @beginTime datetime,
  @endTime datetime,
  @gradeScaleId1 int,
  @gradeScaleId2 int,
  @period tinyint,
  @maxSize tinyint,
  @meetingDays nvarchar(7)
) 
As
 set nocount on 
 
 if exists(select * from [group] where groupId = @groupId)
   begin
       update [group] set locationId = @locationId,[name]= @name,
         description = @description, beginDate = @beginDate, endDate = @endDate,
         beginTime = @beginTime,endTime = @endTime, gradeScaleId1 = @gradeScaleId1,
         gradeScaleId2 = @gradeScaleId2,period= @period,maxSize = @maxSize,
         meetingDays = @meetingDays
         where groupId = @groupId 
         return 0 
     end
   else
     begin
       raiserror('Location does not exist',-1,-1) with nowait                      
       return 1
     end

Go