Forum Discussion

pmscorca's avatar
pmscorca
Icon for Post Prodigy rankPost Prodigy
2 years ago
Solved

Looping to copy tables in a dynamic manner using T-SQL

Hi, I need to copy several tables from a lakehouse to a warehouse and in order to accomplish a such task I'd like to implement a T-SQL stored procedure writing a dynamic loop. Now, how I could do i...
  • NandanHegde's avatar
    2 years ago

    In case of meta data driven farmework, you would need a config table to manage the list of lakehouse table you want to copy into warehouse.

    Then you can query the lakehouse within the warehouse:

    https://www.linkedin.com/pulse/querying-lakehouse-data-from-warehouse-microsoft-fabric-jovan-popovic

     

    And using While loop, you can write a dynamic stored procedure to iterate over the table list and clone them within warehouse via EXECUTE keyword

     

    example : Execute('Select * from table 1')

    rather than select you can write the clone command