how to delete data from table

Please support our MS SQL advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jun 2007
Posts: 19
Reputation: Es Sayen is an unknown quantity at this point 
Solved Threads: 0
Es Sayen Es Sayen is offline Offline
Newbie Poster

how to delete data from table

 
0
  #1
Jun 21st, 2007
hello,

i have a table having 4000 (four thousand) records and now i want to delete 3000 of them as i don't need them, these records have primary key as id which is ofcourse unique.
can anyone tell me how can i delete these records with one query.
if their is any other method please let me know.

Thanks in advance.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,609
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 464
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: how to delete data from table

 
0
  #2
Jun 23rd, 2007
So is there any special criteria which distiguishes these 3000 records from the other records. If there is, you can use that clause to delete the required rows. If this is just a mass delete and if your primary key is ordered, you can delete the rows based on the value of primary keys.

  1. DELETE FROM mytable
  2. WHERE key <= 3000;
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 19
Reputation: Es Sayen is an unknown quantity at this point 
Solved Threads: 0
Es Sayen Es Sayen is offline Offline
Newbie Poster

Re: how to delete data from table

 
0
  #3
Jun 25th, 2007
hello,

no there is no pattern and i have primary key to distinguish those records and i have to delete them randomly.
e.g. from 1-4000 series, i have to delete 2-7, 9-11, 25-36, 40, 45, 78 and so on, without any pattern.

Thank You.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,609
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 464
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: how to delete data from table

 
0
  #4
Jun 25th, 2007
If you don't care about the values which get deleted, then why not just use the method suggested by me above? If not, then you need to know Transact SQL to generate random numbers and delete entries with those primary keys.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,086
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 125
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: how to delete data from table

 
0
  #5
Jun 28th, 2007
use the IN clause
or
simply write a procedure and pass the values. that u want to delete.
Share your Knowledge.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 149
Reputation: Geek-Master is an unknown quantity at this point 
Solved Threads: 6
Geek-Master's Avatar
Geek-Master Geek-Master is offline Offline
Junior Poster

Re: how to delete data from table

 
0
  #6
Jul 6th, 2007
As a long term fix, I would suggest altering the data table to include a code or date field to go by in the future. That's if you have authorization to alter the data table.
If in doubt, reach into the trash can and remove the user guide.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 1
Reputation: endrum18 is an unknown quantity at this point 
Solved Threads: 0
endrum18's Avatar
endrum18 endrum18 is offline Offline
Newbie Poster

Re: how to delete data from table

 
0
  #7
Nov 4th, 2008
Truncate table "tablename" it will delete all ur data from ur table
Thanks
Suba Ganesh( Software Engineer )
Version Software Solutions
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 2
Reputation: ultimahosts is an unknown quantity at this point 
Solved Threads: 0
ultimahosts ultimahosts is offline Offline
Newbie Poster

Re: how to delete data from table

 
0
  #8
Sep 29th, 2009
Truncate tables code worked a treat thanks
Worldwide Windows VPS Hosting Solutions
Ultima Hosts LLC - Since 2005
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC