How to write a foreach in SQL Server?

You seem to want to use a CURSOR. Though most of the times it’s best to use a set based solution, there are some times where a CURSOR is the best solution. Without knowing more about your real problem, we can’t help you more than that:

MySQL: Can’t create table (errno: 150)

From the MySQL – FOREIGN KEY Constraints Documentation: If you re-create a table that was dropped, it must have a definition that conforms to the foreign key constraints referencing it. It must have the correct column names and types, and it must have indexes on the referenced keys, as stated earlier. If these are not satisfied, MySQL … Read more

Incorrect syntax near ”

Such unexpected problems can appear when you copy the code from a web page or email and the text contains unprintable characters like individual CR or LF and non-breaking spaces.