Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. SELECT * INTO #sample FROM (VALUES (1, 'A'),(1,'Long A'),(2,'B'),(2,'Long B'),(2,'BB')) T(ID,Txt)
  2.  
  3. DELETE S FROM (SELECT *, ROW_NUMBER() OVER (PARTITION BY ID ORDER BY LEN(Txt) DESC) RN FROM #sample) S WHERE RN!=1
  4.  
  5. SELECT * FROM #sample
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement