Second question is harder to tell when we know nothing about @divstr looksCREATE procedure GetDivisionKeyAssigEmployee( @empid varchar(20), @tpid varchar(20), @divstr varchar(20), @rs tinyint OUTPUT)asSET NOCOUNT ONdeclare @ekey char(2), @divs2 varchar(10)select @ekey = empe_keyfrom vw_employeewhere tpa_id = @tpid and empr_id = @empidselect @divs2 = division_keyfrom vw_employee_misc_datawhere tpa_id = @tpid and empe_key = @ekeyif @divs2 = substring(@divstr, 1, charindex(',', @divstr, 1) - 1) select @rs = 1else if @divs2 = substring(@divstr, charindex(',', @divstr, 1) + 1, 2) select @rs = 1 else if @divs2 = substring(@divstr, charindex(',', @divstr, charindex(',', @divstr, 1) + 1), 2) select @rs = 1 else select @rs = 0
Peter LarssonHelsingborg, Sweden