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

Comments

Popular posts from this blog

Always On FailOver Events

SSAS Cube or Database backup with Powershell command "Backup-AsDatabase"

Rule "Not Clustered o the Cluster Service is up and online. " FAILED, The machine is clustered but the cluster is not online.