BDG Scenario 3

lw_addPersonGroup.sql

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

CREATE Procedure lw_addPersonGroup
(
        @personId int,
        @groupId int,
        @personType nvarchar(1) = N'I',
        @gradeScaleId int = null,
        @personGroupId int OUTPUT
)
As
    set nocount on
    if @gradeScaleId = null
       select @gradeScaleId = gradeScaleId1 from [group] where groupId=@groupId
    insert into personGroup values(@personId,@groupId,@personType,@gradeScaleId)
    select @personGroupId=@@IDENTITY
    return @@ERROR

Go