August 18, 2003 at 7:54 am
Help! Can I run dynamic SQL in a second process from a stored procedure.
I pull SQL from a table and execute it dynamically using EXEC(@sql), the generated result set is inserted into a temp table. I can handle most errors by checking @@error, but some errors will cause a general failure of the calling stored procedure. Because the SQL that is run is data, it could produce compile errors. Can I insulate the calling stored procedure by running the dynamic SQL in a second process and still return a result set. I would have more peace of mind if I new that any mistake in the dynamic SQL could be logged but have calling process continue.
August 18, 2003 at 9:28 am
You can't do this from standard T-SQL. The only way is to implement an extended stored procedure that spawns a separate thread. Don't know how to return a result set from this though.
August 19, 2003 at 3:04 am
something really dirty 😉 would be:
use xp_xmdshell to execute osql.exe which in turn runs your script ...
(don't try this at home)
best regards,
chris.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply