MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 8th, 2008, 09:06 AM
lapta lapta is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 2 lapta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 39 m 31 sec
Reputation Power: 0
Help with a quarry

I have a database it is made up of about 30 tables.

The database is used for a game server.

When someone deletes there char the char isn't removed from the database, so today i manually deleted all the deleted chars, about 13,000 in total.

The problem is the char names and details are stored in 4 other tables, and i need to delete them from these tables.

So i now have a list of 13,000 names (in a text file at the moment), but i am unsure of how to add them to a query.

Any one got any ideas?

Thanks

lapta

Reply With Quote
  #2  
Old July 8th, 2008, 09:17 AM
ScottyDoesKnow ScottyDoesKnow is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 3 ScottyDoesKnow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 28 m 17 sec
Reputation Power: 0
I don't know about your current problem, but for the future I would suggest modifying your foreign key relations and set the Delete rule to Cascade. That way when you delete a character it will automatically delete all that other stuff.

Reply With Quote
  #3  
Old July 8th, 2008, 09:32 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,808 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 21 h 29 m 33 sec
Reputation Power: 278
Quote:
Originally Posted by lapta
...
So i now have a list of 13,000 names (in a text file at the moment), but i am unsure of how to add them to a query.
...
Load them in a staging table and use it in your delete query.

Reply With Quote
  #4  
Old July 8th, 2008, 09:34 AM
lapta lapta is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 2 lapta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 39 m 31 sec
Reputation Power: 0
Quote:
Originally Posted by pabloj
Load them in a staging table and use it in your delete query.


how would i do that?

Reply With Quote
  #5  
Old July 8th, 2008, 09:34 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,808 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 21 h 29 m 33 sec
Reputation Power: 278
Quote:
Originally Posted by ScottyDoesKnow
I don't know about your current problem, but for the future I would suggest modifying your foreign key relations and set the Delete rule to Cascade. That way when you delete a character it will automatically delete all that other stuff.
I'd not do this as it can have unwanted and destructive results, I'd rather have a
1. restrict
or
2. set null

rule so that:

1. You have to clean up dependent tables before deleting
or
2. You can easily find out the rows related to the item you deleted
Comments on this post
mkhan agrees: I am agree with pabloj

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Help with a quarry


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway