July 17, 2006 at 11:57 pm
Hi,
I have dynamically generate some stored procedure script through another main stored procedure. The output of the main stored procedure has one stored procedure script stored in table. Now what i need is that i have to run this generated stored procedure into the database through the main stored procedure itself. I need a solution on this??????
Thanks in advance,
MK
July 18, 2006 at 3:04 am
Use 'sp_executesql' Statement
July 19, 2006 at 10:23 am
Forgive me if you have a TRULY unique situation there and really do have to do what you're doing, but generally speaking I'd advise against what you're doing. Again GENERALLY speaking, it's best to write a stored procedure which uses parameters to achieve what you want directly.
It might seem like a great idea and novel solution, but if a stored procedure can write another stored procedure, it can generally also execute the same code itself.
You should really ask yourself is there a very good reason why you HAVE to do this? It seems to me (without knowing your situation), that it will be unnecessarily slow.
I'd be very interested to know what unique situation you have which has made this necessary.
July 19, 2006 at 10:25 am
Very goog points Chris ! I am curious as well.
RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."
July 19, 2006 at 11:45 pm
Hai,
My situation is that, i am trying to write a dynamic form of stored procedures for each tables in a database. i.e If one table is created in DB means i need 3 procedures for this table to insert, update and delete a record. So i try to write one main stored procedure with table name as a parameter and this will generate the script for all the above 3(insert,update,delete) procedures in to the database.
Now my problem is that the script generation is fine in my main Sp but i dont know how to execute that script in to the database through main SP. Suggest me some solutions.
Thanks,
MK
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply