Transfer data from one database to another database

how to get data from one database and paste it into another database table ... I cannot do this. Please help me transfer data from one to another. thanks in advance...

+60
sql sql-server sql-server-2008
Apr 05 2018-12-12T00:
source share
7 answers

http://okayguru.blogspot.co.uk/2012/03/copy-one-database-to-another-database.html

There are several ways to do this, below are two options:

Option 1 - Right-click on the database that you want to copy.

  • Choose Tasks> Generate Scripts

  • 'Select specific database objects

  • Check Tables

  • Mark "Save in a new query window"

  • Click Advanced

  • Set "Data Types in Script" to "Schema and Data"

  • Next, Next

Now you can run the generated query in a new database.

Option 2

  • Right-click on the database you want to copy.

  • 'Tasks'> 'Export Data'

  • Next, Next

  • Select a database to copy tables to

  • Mark "Copy data from one or more tables or views"

  • Select the tables you want to copy

  • Done

+107
Apr 05 2018-12-12T00:
source share
β€” -

An example to insert into values ​​in one database table into another database table

insert into dbo.onedatabase.FolderStatus ( [FolderStatusId], [code], [title], [last_modified] ) select [FolderStatusId], [code], [title], [last_modified] from dbo.Twodatabase.f_file_stat 
+15
Jun 20 '15 at 7:10
source share

For those on Azure, follow these modified virus instructions:

  • Open SSMS.
  • Right-click the database in which you want to copy data from .
  • Choose Generate Scripts β†’ Select Specific Database Objects β†’ Select the tables / objects that you want to transfer. strong text
  • In the Save To File panel, click Advanced.
  • Set "Data Types in Script" to Schema and Data
  • Set "Script DROP and CREATE" to Script DROP and CREATE
  • In the "Table / View Options" section, set the appropriate items to TRUE. Although I recommend setting everything to TRUE just in case. You can always change the script after creating it.
  • Set file path β†’ Next β†’ Next
  • Open the newly created SQL file. Remove "Use" from the top of the file.
  • Open a new query window in the destination database, paste the script contents (without use) and execute.
+6
Mar 15 '16 at 17:29
source share

if both databases are on the same server and you want to transfer the whole table (make a copy of it), then use a simple select in statement ...

 select * into anotherDatabase..copyOfTable from oneDatabase..tableName 

You can then write the top of the sysobjects cursor and copy the entire set of tables this way.

If you need more complex data extraction and transformation, use SSIS and create an appropriate ETL in it.

+4
Apr 05 2018-12-12T00:
source share
  • You can back up and restore the database using Management Studio.
  • Again from Management Studio you can use the β€œcopy database”.
  • you can do it manually if there is a reason for this. I mean manually create the target db and manually copy the data using sql statements ...

Can you clarify why you are asking about this? Don't you have experience with this or anything else?

+3
Apr 05 2018-12-12T00:
source share

There are several options and depends on your needs. See the following links:

+2
Apr 05 2018-12-12T00:
source share

These solutions work if the target database is empty. If both databases already have some data, you need something more complex http://byalexblog.net/merge-sql-databases

+2
May 27 '16 at 9:00 a.m.
source share



All Articles