Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Deleting data from tables, keeping structure Expand / Collapse
Author
Message
Posted Thursday, May 8, 2008 11:55 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, June 16, 2008 3:55 PM
Points: 1, Visits: 6
Hi,
I need to be able to delete all the data from 10 different tables and then import a cvs file to update data. Using "truncate" i get error
Cannot truncate table 'tblname' because it is being referenced by a FOREIGN KEY constraint

how do i go around this? Thanks!
Post #497314
Posted Thursday, May 8, 2008 12:05 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 2:08 PM
Points: 7,105, Visits: 15,432
You could simply go

Delete from Mytable

It doesn't have the same limitations as TRUNCATE TABLE, although you will have to empty the tables in the "right order" (delete the rows from Children table first, then the Parent tables).


----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
Post #497322
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse