Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

delete table issues

Posted on 2010-09-07
6
Medium Priority
?
423 Views
Last Modified: 2012-06-21
Hi,

I have created a few tables into a DB.
For some reason I need to remove all the tables I have created.
I have removed all the tables except one.

I am getting an error like this while trying the sql

delete from MappedRuleSet

Msg 547, Level 16, State 0, Line 1
The DELETE statement conflicted with the REFERENCE constraint "MappedRuleSet_TitleFilePartMapping_FK1". The conflict occurred in database "SS_TEST", table "dbo.TitleFilePartMapping", column 'MappingRuleSetID'.
The statement has been terminated.

Regards
la
0
Comment
Question by:la-tempestad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 

Expert Comment

by:intelligenceon17
ID: 33616019
ya surely this will give error because u hve connected  many tables with each other .. since u hve used table columns from  more than one table in one table surely it will give error .. this has only one soltuion tht u shuld make remove constraint from it .. then del the table u want..
0
 
LVL 1

Author Comment

by:la-tempestad
ID: 33616125
So how do I remove the constraints using SQL or Enterprise manager.
I never did it before.


thanks
la
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33616157
Hi,

You no need to drop constraint.
if you already delete data from TitleFilePartMapping then you can u delete from MappedRuleSet.

check there is data in TitleFilePartMapping.
0
 
LVL 3

Accepted Solution

by:
dpicco earned 340 total points
ID: 33616159
Hi la-tempestad,

The TitleFilePartMapping table has a column MappingRuleSetID that is a foreign key back to the table you need to delete. You will have to either:
1. Remove the data in TitleFilePartMapping that is related to data in the MappedRuleSet table using a statement such as this

delete from dbo.TitleFilePartMapping where mappedrulesetid = (select id from MappedRuleSet)

OR

2. Remove the foreign key before deleting the MappedRuleSet table using a statement such as this:

ALTER TABLE dbo.TitleFilePartMapping
DROP CONSTRAINT MappedRuleSet_TitleFilePartMapping_FK1

Hope this helps you. Please let us know if we can assist further.
dpicco
0
 
LVL 19

Assisted Solution

by:Bhavesh Shah
Bhavesh Shah earned 160 total points
ID: 33616178

Table "TitleFilePartMapping" is child Table and MappedRuleSet is Master Table.

So its advised that you should not delete data from MappedRuleSet, if u dont want to delete data from "TitleFilePartMapping"

Still if u want to drop constraint then
Open Management Studio
Select DataBase
Select Table -TitleFilePartMapping
expand the table by clicking on +

Select Key and then select MappedRuleSet_TitleFilePartMapping_FK1

RIGHT CLICK AND REMOVE
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

596 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question