How to copy table with indexes and store procedures?

OGINTZ Marina 175 Reputation points
2024-01-17T13:12:45.2433333+00:00

Hi, I have pipeline that use lookup to get all the tables name and then I preform a copy of all the tables from source to target. I noticed that it doesn't copy indexes and store procedure. Can you please assist me how to do it?

Azure SQL Database
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,623 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Azar 29,520 Reputation points MVP Volunteer Moderator
    2024-01-17T13:20:41.7666667+00:00

    Hey OGINTZ Marina

    I think you need to separately manage the copying of indexes and stored procedures, as they are not automatically included in a typical table copy operation.

    lemme help you on how to do this.

    Use your preferred method to copy tables from the source to the target. Tyou can do this through tools like Azure Data Factory, SSIS.

    Identify and script out the indexes from the source database. You can use SSMS to generate scripts for each index.

    In SSMS, you can script indexes by right-clicking on the table, selecting "Script Table as," and choosing "CREATE To" or "DROP and CREATE To" for scripting the index. Run the generated scripts on the target database.

    Similarly, script out the stored procedures from the source database using SSMS, Right-click on the stored procedure, select "Script Stored Procedure as," and choose "CREATE To" or "DROP and CREATE To" for scripting the stored procedure.

    Finally run the stored procedure scripts on the target database. If this helps kindly accept the answer thanks much.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.