Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Delete all but top 100 rows
Message
 
 
To
15/05/2014 10:27:34
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01600029
Message ID:
01600030
Views:
60
>HI
>
>Whats the easiest way to delete all but the top 100 rows from a table.
>
>I'm testing somehting but I don't want to shove tens of thousands of records through it yet.
>
>Thanks
>
>Nick

The simplest way will be (assuming you can truncate the table)
select top (100) * into #SaveResults from TableToClean order by SomeColumn
truncate table TableToClean
insert into TableToClean
select * from #SaveResults
drop table #SaveResults
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform