Whenever I am building out dynamic SQL I always use SET QUOTED_IDENFITIER OFF first and then use double quotes in the outer sections of text. Then I never have to worry about how many stupid single quotes I need to string together to get the various requirements needed!! 😎
Best,
Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru on googles mail service