Create table with string identity column
CREATE TABLE Alpha
(
ID int IDENTITY(0,1),
AlphaID as 'PY'+RIGHT('00'+CONVERT(VARCHAR,ID),3)PERSISTED PRIMARY KEY,
[DESC] VARCHAR(64) DEFAULT(''),
ModifiedDate DATETIME DEFAULT(GETDATE())
)
INSERT Alpha
DEFAULT VALUES
INSERT Alpha
DEFAULT VALUES
INSERT Alpha
DEFAULT VALUES
INSERT Alpha
DEFAULT VALUES
INSERT Alpha
DEFAULT VALUES
SELECT * FROM Alpha
(
ID int IDENTITY(0,1),
AlphaID as 'PY'+RIGHT('00'+CONVERT(VARCHAR,ID),3)PERSISTED PRIMARY KEY,
[DESC] VARCHAR(64) DEFAULT(''),
ModifiedDate DATETIME DEFAULT(GETDATE())
)
INSERT Alpha
DEFAULT VALUES
INSERT Alpha
DEFAULT VALUES
INSERT Alpha
DEFAULT VALUES
INSERT Alpha
DEFAULT VALUES
INSERT Alpha
DEFAULT VALUES
SELECT * FROM Alpha
Comments