SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Truncate All Tables Part 2


Truncate All Tables Part 2

Author
Message
Jorge Novo-@ETLDEVDBA
Jorge Novo-@ETLDEVDBA
SSC-Addicted
SSC-Addicted (461 reputation)SSC-Addicted (461 reputation)SSC-Addicted (461 reputation)SSC-Addicted (461 reputation)SSC-Addicted (461 reputation)SSC-Addicted (461 reputation)SSC-Addicted (461 reputation)SSC-Addicted (461 reputation)

Group: General Forum Members
Points: 461 Visits: 251
Comments posted to this topic are about the item Truncate All Tables Part 2
ramu.valleti
ramu.valleti
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1011 Visits: 340
Hello there,

when i execute part1 and part2 together the whole query is executing properly, but it is not restoring the FK constraints properly.

can anybody help me on this regard?.....


Thanks&Regards,
Ramu

Ramu
No Dream Is Too Big....!
Jorge Novo-@ETLDEVDBA
Jorge Novo-@ETLDEVDBA
SSC-Addicted
SSC-Addicted (461 reputation)SSC-Addicted (461 reputation)SSC-Addicted (461 reputation)SSC-Addicted (461 reputation)SSC-Addicted (461 reputation)SSC-Addicted (461 reputation)SSC-Addicted (461 reputation)SSC-Addicted (461 reputation)

Group: General Forum Members
Points: 461 Visits: 251
What's seems to be the problem
ramu.valleti
ramu.valleti
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1011 Visits: 340
I've a database which has, two dimension and one fact table.

when i run the script, it is restoring primary keys successfully, but not FK relations in the fact table.

I mean my fact table doesn't hold any relation with the dimension tables after running the script.

Please tell me what might be the problem?.. is it with my database or script?



Regards,
Ramu

Ramu
No Dream Is Too Big....!
Jorge Novo-@ETLDEVDBA
Jorge Novo-@ETLDEVDBA
SSC-Addicted
SSC-Addicted (461 reputation)SSC-Addicted (461 reputation)SSC-Addicted (461 reputation)SSC-Addicted (461 reputation)SSC-Addicted (461 reputation)SSC-Addicted (461 reputation)SSC-Addicted (461 reputation)SSC-Addicted (461 reputation)

Group: General Forum Members
Points: 461 Visits: 251
One of the problems that I see a lot is that when trying to restore the relationship there are orphans on the tables. Ensure that all the foreign keys from the parent are present on the tables. For example. If table A has ID ( 1,2,3,4,5,6) and a child table B has the FK's (1,4,5,6) After dropping all the constraints we delete the records (5,6) on table A but fail to delete records (5,6) on table B, the script will fail to restore the constraint between Table A and B because now B has FK's (5,6) as orphans. The issue can be many things but I will start to look into the orphan issue First. Can you send the DDL of the tables? or a similar DDL I just want to see the kind of constraint between the tables.
dhearne
dhearne
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 31
Jorge,

This is great stuff!

However, it seems as though the restore portion does not correctly restore relationships that are based on more than one column.

I think there needs to be a loop in the dynamic sql section that will iterate through the values in the sysforeignkeys.keyno field. You capture that data in the first part, but do not appear to use it in the restore process.

If I am incorrect, my sincerest apologies. I ask only because I would hate to lose the multi-column FK relationships on my databases!

-Dave
Iwas Bornready
Iwas Bornready
One Orange Chip
One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)

Group: General Forum Members
Points: 29558 Visits: 885
Thanks for the script.
Iwas Bornready
Iwas Bornready
One Orange Chip
One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)

Group: General Forum Members
Points: 29558 Visits: 885
...still a bit scary.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search