[sql-server] How to write a foreach in SQL Server?