Forum Discussion

theknk1223's avatar
theknk1223
Copper Contributor
Apr 22, 2024

HELP with CTE or a Cursor to update multiple rows in 1 table ..selecting from Multiple databases

Server A 
Syetemtable of Dbname= ABC 
Dbnameproductid
ABC123
  
Syetemtable of Dbname= XYZ 
Dbnameproductid
ABC987
  
Syetemtable of Dbname= AQW 
Dbnameproductid
AQW123456
  
Like we have 1000 DB's in Server A and each db has a system table 
  
1 Main LOGIN info table in Server A Dabatase DB1 
SELECT * from DB1. DBO.LOGIN table 
DBNameproduct ID
ABCNULL
XYZA9065
AQWmailto:33c@1442
these rows in 1 main Login table are not  matching the system table rows of each individual Databases 
  
Now I want to update  1 Main LOGIN info table in Server A Dabatase DB1, so that I get results matching each login table of all db's 
SELECT * from DB1. DBO.LOGIN table 
DBNameproduct ID
ABC123
XYZ987
AQW123456
  

3 Replies

  • olafhelper's avatar
    olafhelper
    Bronze Contributor
    Sorry to say, but your post is hard toe read and very unclear; I don't understand a single word.
    What for "system table(s)" do you mean?
    Please post table design as DDL, some sample data as DML statement and the expected result.
    • theknk1223's avatar
      theknk1223
      Copper Contributor

      olafhelper : thank you for looking ..please see below..

       

       

       

      SQL Server Instance=A
      Dbname=ABC
      SELECT * from Table1
      Dbname productid
      ABC 123

       

      SQL Server Instance=A
      Dbname=XYZ
      SELECT * from Table2
      Dbname productid
      XYZ 987



      SQL Server Instance=A
      Dbname=AQW
      SELECT * from Table3
      Dbname productid
      AQW 123456


      Like we have 1000 DB's in Server A and each db has a table which hold productid's


      1 Main LOGIN info table in Server A
      Dabatase DB1
      SELECT * from DB1. DBO.LOGIN table
      DBName product ID
      ABC NULL
      XYZ A9065
      AQW 33c@1442

      these rows in 1 main Login table are not matching the tables( Table1, table2, tale3) rows of each individual Databases

      Now I want to update 1 Main LOGIN info table in Server A Dabatase DB1, so that I get results matching each login table of all db's
      SELECT * from DB1. DBO.LOGIN table
      DBName product ID
      ABC 123
      XYZ 987
      AQW 123456

Resources