hxkresl (12/24/2011)
Dev, I did this already.I executed the stored procedure and then the query.
Will you kindly explain you initial point, so that I can understand where you were going with it?
You are calling a Stored Procedure that is accepting Query components as parameters, generating a query at runtime & executing.
For debugging purpose I modified that SP. It will just print the SQL query, won’t execute it.
--EXECUTE THE CONSTRUCTED INSERT SQL STRING
PRINT @SSQL -- DEBUGGING
--EXEC (@SSQL) -- EXECUTION
When you will run your code it will print the BAD query that is causing error. And many of us (in SSC forum) will be able to help you.