Groups | Blog | Home
all groups > sql server (alternate) > february 2004 >

sql server (alternate) : Delete rows from table


carmenpuccio NO[at]SPAM yahoo.com
2/6/2004 3:32:12 PM
Dan Guzman
2/7/2004 4:21:21 AM
There are no 'first' rows because a relational database table is an
unordered set of rows. That said, below are a couple of methods that will
delete up to 100000 rows.

--primary key is MyKey
DELETE FROM MyTable
WHERE MyTable.MyKey
IN
(
SELECT TOP 100000 MyKey
FROM MyTable
ORDER BY MyKey
)

--no primary key
SET ROWCOUNT 100000
DELETE FROM MyTable
SET ROWCOUNT 0

--
Hope this helps.

Dan Guzman
SQL Server MVP

[quoted text, click to view]
possible?

joe.celko NO[at]SPAM northface.edu
2/7/2004 1:01:04 PM
[quoted text, click to view]
Is this possible? <<

This actually makes no sense. The basic idea of a table is that it is
an unordered set of values; there is no "first" or "next" or "last";
it is not anything like a sequential file.

Tye next basic idea is that rows are found by logic, not by counting
their **physical** position in **physical** storage.

Please read a book or take an RDSBMS course so you'll have some
carmenpuccio NO[at]SPAM yahoo.com
2/8/2004 10:20:21 AM
[quoted text, click to view]

Actually I meant to say the oldest rows and the script that was given
to me is exactly what I needed and I appreciate it. As for you, go to
AddThis Social Bookmark Button