Μέχρι τώρα στον για να διαγράψουμε διπλές εγγραφές σέ ένα πίνακα που δέν έχει Primary Key χρησιμοποιούσαμε την SET ROWCOUNT 1
Δηλαδή κάναμε το παρακάτω .
SET ROWCOUNT 1
Delete myTableName where ID=1
SET ROWCOUNT 0
Αυτό συνεχίζει να ισχύει και στον SQL2005 αλλά μπορεί να γίνει χρησιμοποιώντας και την TOP
DELETE TOP(1) FROM myTableName WHERE ID = 1
Γιατί θα μου πείτε πρέπει να χρησιμοποιούμε την TOP και όχι την ROWCOUNT η απάντηση έρχεται από την ίδια την Microsoft όπως φαίνεται παρακάτω.
Using SET ROWCOUNT will not affect DELETE, INSERT, and UPDATE statements in the next release of SQL Server. Avoid using SET ROWCOUNT together with DELETE, INSERT, and UPDATE statements in new development work, and plan to modify applications that currently use it. Also, for DELETE, INSERT, and UPDATE statements that currently use SET ROWCOUNT, we recommend that you rewrite them to use the TOP syntax.