Hi Razvan -
Thanks for the input. Unfortunately, we are not SQL 2005 yet. Though, I
was able to figure out the solution using Cursor, While loop and the
temp tables. It is working fine - though after researching a little bit
- I came across some Extended Stored Procs such as sp_OACreate etc.
that allows to create an object and then properties can be assigned to
this object. I am hoping to get this done using these extended stored
procs if possible. Anyone, with experience with these procs, please let
me know. Not sure, how this impacts the performance either. I will have
to do a little research to figure this out - I can post the code, if
anyone is interested.
Thanks..
[quoted text, click to view] Razvan Socol wrote:
> Hello, VJ
>
> If you are using SQL 2005, read the following article by Itzik Ben-Gan,
> especially the part about recursive CTE-s (see Figure 8 in the
> article):
>
http://msdn.microsoft.com/msdnmag/issues/04/02/TSQLinYukon/ >
> Razvan
Hi, VJ
I believe a solution using temp tables and a while loop (without
cursors) would be possible and more efficient (if all rows for a
particular level are processed at the same time). Also, if you don't
allow more than 30 levels of nesting for the components, you can use
recursive UDF-s (which seem more elegant and possibly have the same
performance).
I would not recommend using sp_OACreate/etc to call some object
repetitively (for each row in a table), because the overhead may be
significant (and even the impact on the stability of the server should
be considered). I think it's better to do the manipulations in SQL if
there is more data. I would use sp_OACreate only if the computations
are very CPU-intensive but require a small amount of data, or if you
really must use some features that are not available in SQL Server.
Razvan