Which Table has to be loaded first ?????

  • Hi,

    Do we have any algorithm or procedure or a user defined function to which i can pass the tables names and it should tell me the loading sequence.

    For example i have 3 tables say A,B,C where A and B are master tables and C is a transactional table which references A(c1) and b(id).

    If i pass the tablenames to the stored procedure/functions, it is should suggest me the loading sequence.

    declare @tableList varchar(100);

    set @tableList = '''C'',''A'',''B''';

    exec sp_showLoadingSequence(@tableList)

    --Expected output

    A,B,C

    If anyone has tried this before????????

    I can go for Database diagram but if we are having large set to tables to be loaded then it is becoming great confusion. so, i thought if we can find out a way from T-SQL then it will be good.

    Any thoughts will be greatly appreciated!

    Thanks in Advance

  • I searched for scripts on this site using the keywords "script table relationship" and found the following link that might get you started:

    http://www.sqlservercentral.com/scripts/scripting/69282/



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • Thanks

  • Hey Lutz,

    The script you mentioned is for different purpose. It is similar to sp_help /to know the structure of a table!!!! 😉

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply