CREATE TABLE
CREATE TABLE dbo.MyTable
(
ID int NOT NULL IDENTITY (1, 1),
Initial nvarchar(10) NULL
) ON [PRIMARY]
GO
Adding Data
INSERT INTO MyTable ( Initial) VALUES ('A') , ('B'), ('C');
select * from MyTable
Customized Identity
ALTER TABLE MyTable ADD BarCode AS '0-' + CAST(Id as nvarchar(16))
select * from MyTable
Combined Identity
ALTER TABLE MyTable ADD PrefixField as Initial + '-' + CAST(Id as Nvarchar(20))
Post a Comment