Solved

delete table issues

Posted on 2010-09-07
6
398 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
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 7

Expert Comment

by:rashmi_vaghela
ID: 33616063
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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 85 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 40 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This collection of functions covers all the normal rounding methods of just about any numeric value.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Viewers will learn how to maximize accessibility options in an Excel workbook for users with accessibility issues.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

760 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now