Hi,
Refer
this link[
^]. This will help you a lot.
Here I modified same thing for you.
Create a
User Defined Function
:
CREATE FUNCTION udf_ZeroPaddingAndConcat (
@Id INT,
@Length INT,
@PaddingChar CHAR(1) = '0'
)
RETURNS NVARCHAR(MAX)
AS
BEGIN
RETURN (
SELECT RIGHT(REPLICATE(@PaddingChar, @Length) + CAST(@Id as nvarchar(10)), @Length)
)
END
GO
Create the Table accordingly:
CREATE TABLE CustomIdentityTable
(
Id int IDENTITY(1,1) NOT NULL,
StringSequence as dbo.udf_ZeroPaddingAndConcat(CAST(Id as nvarchar(10)),6,'0'),
BookName nvarchar(250),
BookDescription nvarchar(max)
)
Now Insert Data:
INSERT INTO CustomIdentityTable VALUES('test', 'test')
--Amit