﻿







CREATE FUNCTION [dbo].[fds__fn_invoice-srq_id] (
)
RETURNS varchar(10)
AS
BEGIN
  DECLARE @NewID varchar(7) = [dbo].[ocms_fn_generatePassword] (7,0,1,0);

  WHILE EXISTS( SELECT * FROM [dbo].[fds__invoice_servicerequests] WITH (SERIALIZABLE) WHERE [id] = @NewID)
	BEGIN
		SET @NewID = [dbo].[ocms_fn_generatePassword] (7,0,1,0);
	END

  RETURN @NewID;
END;