Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. DELETE FROM Table WHERE ID NOT IN (SELECT TOP 10 ID FROM Table)
  2.  
  3. DELETE FROM Table WHERE ID NOT IN (SELECT TOP 10 ID FROM Table)
  4.  
  5. create table #nuke(NukeID int)
  6.  
  7. insert into #nuke(Nuke) select top 1000 id from article
  8.  
  9. delete article where not exists (select 1 from nuke where Nukeid = id)
  10.  
  11. drop table #nuke
  12.  
  13. DELETE FROM table
  14. WHERE id NOT IN (SELECT id FROM table ORDER BY id LIMIT n);
  15.  
  16. DELETE
  17. Product
  18. FROM
  19. Product
  20. LEFT OUTER JOIN
  21. (
  22. SELECT TOP 10
  23. Product.id
  24. FROM
  25. Product
  26. ) TopProducts ON Product.id = TopProducts.id
  27. WHERE
  28. TopProducts.id IS NULL
  29.  
  30. declare @n int
  31. SET @n = SELECT Count(*) FROM dTABLE;
  32. DELETE TOP (@n - 10 ) FROM dTable
  33.  
  34. DELETE TOP 90 PERCENT FROM dTABLE;
  35.  
  36. Delete article where id not in (select top 1000 id from article)
  37.  
  38. Delete a From Table a Inner Join (
  39. Select Top (Select Count(tableID) From Table) - 10)
  40. From Table Order By tableID Desc
  41. ) b On b.tableID = A.tableID
  42.  
  43. WITH CTE AS
  44. (
  45. SELECT ID
  46. FROM dbo.TableName
  47. ORDER BY ID DESC
  48. OFFSET 11 ROWS
  49. )
  50. DELETE CTE;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement