Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Delete all but top 100 rows
Message
From
15/05/2014 10:34:08
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01600029
Message ID:
01600032
Views:
49
>>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
Thanks Naomi

having a brain dead afternoon I decided to delete all but 100 rows as it really didn't matter what I kept.

Nick
Previous
Reply
Map
View

Click here to load this message in the networking platform