• Eirikur Eiriksson (12/27/2015)


    Jeff Moden (12/27/2015)


    C@mel (12/27/2015)I don't want to restore a backup of A. to B.

    I want a script to copy all data from A. to B.

    WHY? To what end? What is the reason for doing it the most difficult way possible instead of the simplest?

    Only reason I can think of for anyone wanting to do this is on the likes of Amazon's RDS where restoring a database from an external backup is not an option.

    😎

    "Quick" solution, in SSMS right click on the database, select Tasks->Generate Scripts... and include the data.

    Gosh, no. Don't include the data unless there's very little. It creates one INSERT with a full list of column names and values per row. If you have a lot of data, it will take a month of Sundays to upload and run. Even RedGate datacompare makes the same kind of mess of things.

    I also agree that the SSMS script generator works a treat except for one thing... it doesn't always follow the correct dependency order. There can also be circular references between tables (not a good idea but it happens) that throw a monkey wrench into the script, however it's generated.

    It would be nice if the OP spoke up as to why the need, right about now.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)