Help with updating tables across hundred of DBs with the same tables.
Hi!
I'm a bit in over my head with this and would appreciate some help. I'm pretty new to sql. But i have a few hundred databases to change and don't want to be forced to do it manually. I want to just make one be correct, and then copy it into all others.
So, here is a small selection data from [SetupCMS].[dbo].[PageTypeTemplateItem] table:
..ItemID | Label | Field | Type | PageTypeID | System UID | Default Value |
5797 | Remove Colors & Fonts | Yes/No | Property | 1117 | remove_colors__fonts | no |
7408 | Upload Logo Icon | Image | Design Attribute | 1117 | ||
5791 | Template 1 FAQ Link | Text field | Content | 1117 | template_1_help_text | https://bogus.com/faq/ |
5896 | Template 2 FAQ Link | Text field | Content | 1117 | template_2_help_text | https://bogus.com/faq/ |
5898 | TOP BAR | Log out | Text field | Content | 1117 | log_out | Log out |
2433 | Template 2 Box 2 Title | Text field | Content | 76 | log_out | null |
This should go into the other tables, like [TrialCMS].[dbo].[PageTypeTemplateItem].
unfortunately, there is also much data that shouldn't be copied.
Only the ones with PageTypeID=1117, where the SystemUID is matching between the DBs, should have all other fields (except the id key) in the row copy the ones in [SetupCMS]. since SystemUID is not unique in the table, but there is only one per PageTypeID. The actual key, PageTypeTemplateItemId, does not match between the different databases so i can't use it.
It feels like it should be doable, but i've so far been unable to hack my way through it with the tutorials and answers to other questions. i've messed around with UPDATE and INNER JOIN mostly.
So, I guess my question is first, am I wrong and it's not doable? writing it out, it does look more complicated than i thought when i started...
And second, if it is doable, how?