I think you're talking about DML, not DDL. In addition, I am somewhat confused when you're talking about getting an error after removing casts. And where qryPN is taken from? It looks like a dynamic SQL, but is done on the front-end...Is it C# you're showing here? It very well may be that qryPN has a NULL value, which results in the entire string to be NULL, thus - "empty ddl." Can you shed some light on all this?