How to copy some objects (tables, views, store procedures) from one DB to another DB?

  • How to copy selected objects (tables(including data), views, store procedures) from one DB to another DB?

  • DDL only, or DDL and also the data?

    if it's just the DDL , i'd use the SSMS scripting wizard.

    IN SSMS Object Explorer,

    Right Click on a specific database.

    Click Tasks>> Generate Scripts.

    Follow the wizard steps.

    For All Data, backup and restore is the #one choice, as it's prone to the fewest errors.

    After that , the Import Export wizard is probably the easiest for selectively grabbing various tables. That's almost the same steps as above:

    Right Click on a specific database.

    Click Tasks>> Export Data.

    Follow the wizard steps to select the target server and which objects..

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • I'd suggest using the scripting wizard or right-clicking on individual objects as well. That generates the script you need and then you can run them on multiple different machines.

    But, if you want to automate it, you might want to look at something like Red Gate SQL Compare[/url]. It'll do the job for you in a much more sophisticated fashion. It allows you to compare the databases and move the objects that are different between the two.

    I do work for Red Gate.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply