Hi
I have a user define function as below, to compute a custom Id using PK Id as guide
CREATE FUNCTION [dbo].[CustomeId] (
@Prefix NVARCHAR(10),
@Id INT,
@Length INT,
@PaddingChar CHAR(1) = '0'
)
RETURNS NVARCHAR(MAX)
AS
BEGIN
RETURN (
SELECT @Prefix + RIGHT(REPLICATE(@PaddingChar, @Length) + CAST(@Id as nvarchar(10)), @Length)
)
END
In my sql table's Computed Column specification I have:
([dbo].[CustomeZoneId]('GH-',CONVERT([nvarchar](10),[Id],(0)),(10),'0'))
and out put is GH-0000000001 , GH-999999999
but I want it to be able to grow to infinity along side the PK Id. something like GH-1 to infinity
What I have tried:
([dbo].[CustomeZoneId]('GH-',CONVERT([nvarchar](10),[Id],(0)),(10),'0'))