Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SQL Server Tip #1: Basic Table Template
CREATE TABLE tempdb.dbo.temp1
(
Temp1Id INT IDENTITY(1,1) NOT NULL
CONSTRAINT temp1PrimaryKey PRIMARY KEY CLUSTERED,
VALUE VARCHAR(25),
DateModified datetime2,
DateCreated datetime2 default getdate()
)
GO
CREATE TABLE tempdb.dbo.temp2
(
Temp2Id INT IDENTITY(1,1) NOT NULL
CONSTRAINT temp2PrimaryKey PRIMARY KEY CLUSTERED,
Temp1Id INT NOT NULL
CONSTRAINT Temp2Temp1ForeignKey FOREIGN KEY (Temp1Id)
REFERENCES dbo.temp1(Temp1Id),
VALUE VARCHAR(25) NULL,
DateModified datetime2,
DateCreated datetime2 default getdate()
)
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.