Skip to content

Instantly share code, notes, and snippets.

@tawman
Created January 29, 2012 22:09
Show Gist options
  • Save tawman/1700953 to your computer and use it in GitHub Desktop.
Save tawman/1700953 to your computer and use it in GitHub Desktop.
PetaPocoHierarchy Organization Table SQL CREATE Script
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Organization](
[Id] [uniqueidentifier] NOT NULL,
[ParentId] [uniqueidentifier] NULL,
[OrganizationCode] [nvarchar](10) NOT NULL,
[Name] [nvarchar](100) NOT NULL,
CONSTRAINT [PK_Organization] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Organization] WITH CHECK ADD CONSTRAINT [FK_Organization_ParentOrganization] FOREIGN KEY([ParentId])
REFERENCES [dbo].[Organization] ([Id])
GO
ALTER TABLE [dbo].[Organization] CHECK CONSTRAINT [FK_Organization_ParentOrganization]
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment