Copy data from one database to another?

Asked

Viewed 553 times

0

Good afternoon, I am beginner in sql server and I came across a situation that raised this doubt. I wonder if it is possible to copy a table from one database to another, in the situation where both are on the same server.

inserir a descrição da imagem aqui If it is not clear the text, it would be as in the image shown, the two banks have exactly the same tables, but the "ORIGIN" has in the table dbo.cidadesibge several records that I would like to put in the database "DESTINATION" in the same table dbo.cidadesibge. I looked in some pages, read that there were some forms, but I could not find any answer that would explain me how to accomplish. I thought to accomplish with "Select * Into" also could not get any way to work in this case, if someone can explain me how to accomplish thank you for the help.

  • 1

    @bfavaretto INSERT INTO Destino.Schema.Tabela (Column1, ..) SELECT Column1,.. FROM ORIGEM.Schema.Tabla;

  • Oops, you’re right @Sami

  • You want to copy all information from BD ORIGIN or just data from dbo.cidadesibge table?

  • in the example situation I gave would be the case of copying the data from the source table to the destination table, knowing that the two are identical in columns and name

2 answers

0


Since the table structures are the same, I advise you to use the following command:

INSERT INTO DESTINO.dbo.cidadesibge

SELECT * FROM ORIGIN.dbo.cidadesibge

I hope I’ve helped.

  • worked out, exactly as I wanted... thank you so much for your help!

-2

You could take a backup of this data and run in this database where you would insert this data and tables. I would at least do that.

  • It wants to make of a table only and not of the entire database. This your solution would overwrite the other data generating other problems.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.