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:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old August 6th, 2004, 07:49 AM
mOrrI mOrrI is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Location: Portugal
Posts: 154 mOrrI User rank is Private First Class (20 - 50 Reputation Level)mOrrI User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 46 m 59 sec
Reputation Power: 5
Send a message via MSN to mOrrI
Question Deleting all rows in a Table

hello there,
what is the code to Delete all rows in a Table????

thanks in advance

Reply With Quote
  #2  
Old August 6th, 2004, 08:22 AM
shammat shammat is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2003
Location: Munich, Bavaria
Posts: 971 shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 44 m 15 sec
Reputation Power: 57
DELETE FROM <tablename>;
COMMIT;

You should get a good SQL manual

Reply With Quote
  #3  
Old August 6th, 2004, 10:25 AM
mOrrI mOrrI is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Location: Portugal
Posts: 154 mOrrI User rank is Private First Class (20 - 50 Reputation Level)mOrrI User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 46 m 59 sec
Reputation Power: 5
Send a message via MSN to mOrrI
nah i expressed my self in the wrong way
i want to ask this:

i got a table with has a column that is a FK of other tables...
so

delete from table1

doesn't work

Reply With Quote
  #4  
Old August 6th, 2004, 04:59 PM
shammat shammat is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2003
Location: Munich, Bavaria
Posts: 971 shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 44 m 15 sec
Reputation Power: 57
Then you have to delete the referenced rows in the other table first...
Or you can drop/disable the FK constraint

Reply With Quote
  #5  
Old August 13th, 2004, 10:35 AM
cell-gfx cell-gfx is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 13 cell-gfx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Just a wonder - does using the TRUNCATE TABLE command override the foreign key constraints? And do you mean that the primary key of the table you're deleting is a foreign key of other tables, or that other table's primary keys are forign keys in this table? Because if it's the second case, I can't see why that constraint would affect you...

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Deleting all rows in a Table


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 2 hosted by Hostway