I am working on a procedure and I am kind of stuck at a point. I have pasted the code below. I understand the code can be improved a lot.. but, I need to see that it is covering all the requirements.
The issue I am facing is.. after I wrote this procedure I understood that I have to disable a constraint before I run this procedure and enable it after this procedure is executed. But I want to incorporate that alter table commands in this procedure itself. I wonder where do I put it in the code below. Another idea I had was to write the drop and creation of the constraints in a separate procedures and call them in this procedure.. but I am not sure how I can do it. These are novice ideas, that I have. I would appreciate if experts help me out. I also wanted to rollback the whole procedure, if at all any error occurred in any of the Begin- end blocks. any comments or suggestions on the code I would take as if I learnt something new :). I have not figured out yet how this code would affect the performance yet. The code that I have written below, propagates same id across different tables, which are connected through constraints. the effort was to minimize writing 6 insert statements explicitly into 6 different tables. Any help is appreciated.
OK, requirements are requirements, and if the circular reference must stay then here is how your procedure might look. The only things I needed to tweak are:
Here is the abridged script:
answered Aug 18 '10 at 02:51 PM
i kind of modified the code and now i am able to rollback the inserted records if anyerrors occur in the following way. But i still wonder how to tweak the constraints in the same procedures.
create PROCEDURE [dbo].[CREATEASSET_MODIFIED]
declare @id int
exec dbo.CREATEASSET_MODIFIED_Auyu ASSET,UNIT,823,@id output,182,182,0,0,0,0,'12-1-2010','12-1-2010',1
answered Aug 18 '10 at 12:50 PM