Forum Discussion

Jonatan_F's avatar
Jonatan_F
Copper Contributor
Sep 19, 2023

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:

..ItemIDLabelFieldTypePageTypeIDSystem UIDDefault Value
5797Remove Colors & FontsYes/NoProperty1117remove_colors__fontsno
7408Upload Logo IconImageDesign Attribute1117  
5791Template 1 FAQ LinkText fieldContent1117template_1_help_texthttps://bogus.com/faq/
5896Template 2 FAQ LinkText fieldContent1117template_2_help_texthttps://bogus.com/faq/
5898TOP BAR | Log outText fieldContent1117log_outLog out
2433Template 2 Box 2 TitleText fieldContent76log_outnull

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?

  • olafhelper's avatar
    olafhelper
    Bronze Contributor
    Your question is much to vague to can be answered.
    Please post table design as DDL, some sample data as DML statement and the expected result.

Resources