How to delete multiple rows in a single query

Posted by Saritha.Rajeshkumar under Sql Server on 4/15/2013 | Points: 10 | Views : 2027 | Status : [Member] | Replies : 3
Hi Sir/Madam

How to delete multiple rows in a single query.

i have 2 columns id and Name , i want to delete the rows from id=100 to 150.

thank you , waiting for ur reply.




Responses

Posted by: Learningtorise on: 4/15/2013 [Member] Starter | Points: 25

Up
0
Down
I am assuming that this query is related to SQL Server

delete from tableName where id between 100 and 150

This will delete rows from your table.....

To test above query:
-- Run this code

begin tran

delete from tableName where id between 100 and 150

-- Run following code to verify result...

Select * from tableName

-- if everything seems fine, run this code
Commit
--Else
Rollback


http://hashtagakash.wordpress.com/

Saritha.Rajeshkumar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Satyapriyanayak on: 4/15/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
DELETE FROM Table
WHERE (id BETWEEN 100 AND 150)

DELETE FROM Table
WHERE (id >= 100) AND (id <= 150)

If this post helps you mark it as answer
Thanks

Saritha.Rajeshkumar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sriramnandha on: 5/11/2013 [Member] Starter | Points: 25

Up
0
Down


DELETE FROM <TABLENAME> WHERE COLUMN NAME BETWEEN 100 AND 150


DELETE FROM <TABLENAME> WHERE (ID <= 100) AND (ID<=150)





sriram

Saritha.Rajeshkumar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response