結果 : how to use cte instead of cursor in sql server