Question: Why am I getting this constraint error when I try and run my ETL? Using SQL server When I create my DwPubsSales database these are

Why am I getting this constraint error when I try and run my ETL? Using SQL server

When I create my DwPubsSales database these are the FK's I coded in /****** Add Foreign Keys ******/ Alter Table [dbo].[DimTitles] With Check Add Constraint [FK_DimTitles_DimPublishers] Foreign Key ([PublisherKey]) References [dbo].[DimPublishers] ([PublisherKey])

Alter Table [dbo].[FactTitlesAuthors] With Check Add Constraint [FK_FactTitlesAuthors_DimAuthors] Foreign Key ([AuthorKey]) References [dbo].[DimAuthors] ([AuthorKey])

Alter Table [dbo].[FactTitlesAuthors] With Check Add Constraint [FK_FactTitlesAuthors_DimTitles] Foreign Key ([TitleKey]) References [dbo].[DimTitles] ([TitleKey]) Go Alter Table [dbo].[FactSales] With Check Add Constraint [FK_FactSales_DimStores] Foreign Key ([StoreKey]) References [dbo].[DimStores] ([Storekey]) Go Alter Table [dbo].[FactSales] With Check Add Constraint [FK_FactSales_DimTitles] Foreign Key ([TitleKey]) References [dbo].[DimTitles] ([TitleKey]) Go Alter Table [dbo].[FactSales] With Check Add Constraint [FK_FactSales_DimDates] Foreign Key ([OrderDateKey]) References [dbo].[DimDates] ( [DateKey] ) Go Alter Table [dbo].[DimTitles] With Check Add Constraint [FK_DimTitles_DimDates] Foreign Key ([PublishedDateKey]) References [dbo].[DimDates] ( [DateKey] )

Then in my ETL I am trying to flush, and in my first step I am getting an error

-- First drop all foreign key constraints

ALTER TABLE dbo.DimTitles DROP CONSTRAINT [FK_DimTitles_DimPublishers]

ALTER TABLE dbo.DimTitles DROP CONSTRAINT [FK_DimTitles_DimDates]

ALTER TABLE dbo.FactSales DROP CONSTRAINT [FK_FactSales_DimTitles]

ALTER TABLE dbo.FactSales DROP CONSTRAINT [FK_FactSales_DimStores]

ALTER TABLE dbo.FactSales DROP CONSTRAINT [FK_FactSales_DimDates]

Go When I run this I get the error:

Msg 3728, Level 16, State 1, Line 1 'FK_DimTitles_DimPublishers' is not a constraint. Msg 3727, Level 16, State 0, Line 1 Could not drop constraint. See previous errors.

Which is refering to this line here: ALTER TABLE dbo.DimTitles DROP CONSTRAINT [FK_DimTitles_DimPublishers] But I don't understand why its sayign this when the database was created fine.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!