SQL : Delete All Records Except Top N Records
-- Test Count Before Delete :
Select count(Id) from [MyTable]
-- Delete All Records Except Top N Records :
DELETE FROM [MyTable] WHERE [Id] NOT IN (SELECT TOP 500 [Id] FROM [MyTable])
-- Test Count After Delete
Select count(Id) from [MyTable]
No comments:
Post a Comment