victorio victorio - 7 months ago 11
SQL Question

How to export all data from table to an insertable sql format?

I have a Table (call it

A_table
) in a database (call it
A_db
) in Microsoft SQL Server Management Studio, and there are 10 rows.

I have an another database (call it
B_db
), and it has a Table (call it
B_table
), which has the same column settings as
A_table
has! But the
B_table
is empty!

What I want:


  • Copy every rows from
    A_table
    to
    B_table
    .



Is there any option in Microsoft SQL Server Management Studio 2012, to create an insert SQL from a table? Or there is any other option to do that?

Thank you!

Answer

Quick and Easy way:

  1. Right click database
  2. Point to tasks
  3. Select generate scripts
  4. Click next
  5. Choose tables
  6. Click next
  7. Click advanced
  8. Scroll to data to script - Called types of data to script in SMSS 2014 Thanks to Ellesedil for commenting
  9. Select data only
  10. Click on 'Ok' to close the advanced script options window
  11. Click next and generate your script

I usually in cases like this generate to a new query editor window and then just do any modifications where needed.