SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Easier way to delete specific records?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

meef
Yak Posting Veteran

90 Posts

Posted - 05/01/2012 :  14:49:34  Show Profile  Reply with Quote
I need to delete 84 records and it's going to be a huge pain typing:

WHERE
name = 'this' OR name 'that' OR....

Is there any other way to delete or am I going to have to sit here and type it all out?

visakh16
Very Important crosS Applying yaK Herder

India
47099 Posts

Posted - 05/01/2012 :  14:52:17  Show Profile  Reply with Quote
you've to either do that or put the required values onto a temporary table and do like

DELETE t
FROM YourTable t
INNER JOIN TempTable tmp
ON tmp.field = t.name
WHERE .... any other conditions


where do you got these values from? is it already present in a master table field?
------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/


Edited by - visakh16 on 05/01/2012 14:53:34
Go to Top of Page

meef
Yak Posting Veteran

90 Posts

Posted - 05/01/2012 :  14:55:12  Show Profile  Reply with Quote
Yeah, there are about 150 total records in a user account table and I need to delete 84 of them.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47099 Posts

Posted - 05/01/2012 :  15:45:48  Show Profile  Reply with Quote
quote:
Originally posted by meef

Yeah, there are about 150 total records in a user account table and I need to delete 84 of them.


get those 84 ids onto a table and use suggested query

other wise form a comma delimited list using 84 values and use dynamic sql

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.3 seconds. Powered By: Snitz Forums 2000