CREATE PROC AddNewWelder (@LowestWelderIdPrefix char(1) = null)
AS
DECLARE @WelderId varchar(3)
BEGIN
IF @LowestWelderIdPrefix = null
BEGIN
SET @LowestWelderIdPrefix = 'A'
END
-- END IF
-- Now we need to look al all the welders with the lowestwelderprefix to see whos number is NOT there
-- We want the min val of what is not in between 1 & 99.
-- If we find this number, we append it to the LowestIdPrefix, setting this as the new weld id and passing it back.
-- Otherwise:
-- We call this procedure again, this time passing in the lowest ID prefix and append 00 to it.
-- Begin
-- SET @CurrentWelderIdPrefix = ( SELECT MIN (ASCII (SUBSTRING (WelderId,1, 1)))
-- FROM Welder
-- WHERE ASCII(SUBSTRING(WelderId, 1, 1)) = @
-- )
-- End
END
RETURN