whenever I use sp_msforeach... I always SET QUOTED_IDENTIFIER OFF first. Then I can use DOUBLE quotes for the outer (executed) strings and then single quotes for inner string creation. Works like a champ, and I never have to worry with is it 1, 2, 3, 4, etc single quotes I have to put together to get the desired effect!! 😎
Best,
Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru on googles mail service