SQL Server Tip #1: Basic Table Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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