Hi I am using sql server 2005 with Windows XP. I have a question on how to load xml data into sql server by applying business logic dynamically. Question: The input is XML file which will have 5000 records. Before loading data into sql server destination tables , I have to apply business logic (2-3 level). what is the best way to achieve this? Would it be feasible to write a stored proc with business logic and call this proc for each record in xml (5k), its a performance overhead I believe. what is the best way to achieve this dynamically I am assuming to follow below approach. 1. read the xml using SSIS and store in sql server staging table 2. read each record and pass it to stored proc (Stored proc will check for the business logic and inserts into multiple tables by checking referential integrity based on the logic). Appreciate your help Thanks PK
Its always a best practices to write your Business logic in stored proc, so if any changes occur (in future) logic the only thing is you have to update the SP. also it will not create any performance overhead. Besides, for your XML data manipulation it would be good to write the logic with in the XP , as you can use XML datatype as well as stored procs for XML manipulation. -Abhijit, MCP
Kind of disagree with the business logic in the stored proc. a little logic for filtering is fine but not have the comple business logic. you should always have a business object which do's this work for you.
I would agree with Abhijit in this regard to build the business logic within Stored PRocedures where by the performance can be sustained for better compilation & caching, also it is better to differentiate the business logic into triggers (less complex calculations) to meet the criteria. http://msdn.microsoft.com/en-us/library/ms345110.aspx & http://msdn.microsoft.com/en-us/magazine/cc163611.aspx articles refers about how you can take advantage within SQL 2005 to mainpulate the XML data.