March 3, 2016 at 6:40 am
I have to add data in tables for a fresh empty database, Don't know the structure but found Foreign Keys implemented in tables.
So I need some kind of script to find recursively tables based on FK references and provide the sequence such that we can add data in tables by that sequence one by one.
Those tables are lookup tables where we want to add data.
Shamshad
March 3, 2016 at 7:00 am
shamshad.ali (3/3/2016)
I have to add data in tables for a fresh empty database, Don't know the structure but found Foreign Keys implemented in tables.So I need some kind of script to find recursively tables based on FK references and provide the sequence such that we can add data in tables by that sequence one by one.
Those tables are lookup tables where we want to add data.
Shamshad
Now we know your requirement, but what is your question?
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
March 3, 2016 at 7:09 am
EXEC sp_msdependencies @intrans = 1
that will give you all objects in foreign key hierarchy order. it can be painfully slow or never ends if you have circular references (TableA -->TableB-->TableA)
basically, if you want to CREATE objects, you create them in that order, lowest to highest
to DELETE or DROP the objects it's from highest to lowest.
Lowell
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply