Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Delete all but top 100 rows
Message
 
 
À
15/05/2014 10:27:34
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01600029
Message ID:
01600030
Vues:
61
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform