Hi, I have a table with One-To-Many reflexive association.
I need insert the first value disabling temporary the constraint. Any idea how to do it?
I use MS SQL 2008, thanks guys for your support!
CREATE TABLE dbo.CmsCategories
(
CategoryId int NOT NULL IDENTITY (0,1) -- Seed = 0 and Increment= 1
CONSTRAINT PK_CmsCategories_CategoryId PRIMARY KEY,
ParentOf int NOT NULL
CONSTRAINT DF_CmsCategories_ParentOf DEFAULT 0
);
ALTER TABLE dbo.CmsCategories
ADD CONSTRAINT FK_CmsCategories_ParentOf FOREIGN KEY (ParentOf) REFERENCES dbo.CmsCategories(CategoryId); -- One-to-many Reflexive association
GO
INSERT INTO dbo.CmsCategories
(ParentOf)
VALUES
(0);