Home > Archive > Microsoft SQL Server forum > September 2005 > Re: filter for DELETE









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: filter for DELETE
Reg

2005-09-30, 1:23 pm


"Joseph" < UseLinkToEmail@dbFor
umz.com> wrote in message
news:4_895190_c1aab0
0d94e6aa5ec49c937f01
815b40@dbforumz.com...
> Hi,
> I don’t know to write SQL command filter.
> m_strQueryDelete.Format("DELETE FROM tab WHERE (Col1 = ’abc’ AND Col2
> = ’abc’ AND ?????)"
> example: ODBC found 100 records.
> I need to delete first 90 records and to leave last 10 records.
>
> Thank you
>
> Joseph


Try this:

I will presume tabID is a primary key for the table:

DELETE
FROM tab
WHERE tabID IN (SELECT top 90 tabID FROM tab WHERE Col1 = ’abc’ AND Col2 = ’
abc’)


Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com