The exec() does return the SQL - look at this image - both recordsets appear at the bottom - one from the "pure select" and one from the "dynamic select"
*** Read the sticky in the DB forum about how to get your question answered quickly!! ***
Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".
Someone here gave me this tip and I'm assuming this is MS SQL. Run the query in Enterprise Mangaer or a native query window and direct the output to text. In my environment its on the Query menu, Results to, Results to text. Sometimes you will see things are returning that do not show in the results grid. Also, although it doesn't look like it here, shutting ANSI warning off will eliminate warning messages you might not care about.
Good point - if you are getting an error (like you might be doing a SUM() and you have NULL's in the field you are summing) that error message might get "in front of the return data" when called from code.
I always create my SPROCS in a QUERY WINDOW - usually with an EXECUTE of that SPROC at the bottom to test it.
Then I save my CREATE SPROC as a .SQL text file...
*** Read the sticky in the DB forum about how to get your question answered quickly!! ***
Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".