Guest User

Untitled

a guest
Aug 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. SQL Server loop in SProc to generate query
  2. SELECT col1
  3. FROM table1
  4. WHERE col2 = 1
  5.  
  6. INTERSECT
  7.  
  8. SELECT col1
  9. FROM table1
  10. WHERE col2 = 2
  11.  
  12. INTERSECT
  13.  
  14. SELECT col1
  15. FROM table1
  16. WHERE col2 = 3
  17.  
  18. SELECT col1
  19. FROM table1 t
  20. INNER JOIN
  21. #temp v
  22. ON (t.col2 = v.col2)
  23. GROUP BY
  24. col1
  25. HAVING COUNT(*) = (SELECT COUNT(*) FROM #temp)
Add Comment
Please, Sign In to add comment