Oh good! I am glad you got it sorted. Don't forget that when you execute it you have to do it like so: EXEC(@sql). As a rule I print it while I am testing the string i.e. PRINT @sql. The print will show you what the command looks like so you can tweak it if needed. |