I know there is a way to display what the final value of @sSQL, but can't remember it. Can someone tell me how, please? Also, if you can spot what my syntax error is that would be great too! Frank, I can't immediately spot the syntax error - however, if you also place a SELECT @sSql at the end of the proc, the procedure will return the string...so you could use that in testing to bring back the value of @sSQL, and perhaps help in your debugging.