如何将数据从一个数据库表复制到sql server中的另一个数据库现有表

时间:2022-09-30 23:05:46

how to copy only data from one database table to another database existing table in sql server query?

如何在sql server查询中只将数据从一个数据库表复制到另一个数据库现有表?

Copy one database existing table to another database existing table. anyone know, Please tell me Sql query Open image

将一个数据库现有表复制到另一个数据库现有表。有谁知道,请告诉我Sql查询打开图片

5 个解决方案

#1


0  

Try this ...

试试这个 ...

INSERT INTO DataBase2.dbo.table2
SELECT * FROM DataBase1.dbo.table1

#2


2  

insert into <target table name>(columns)
select columns 
from <source table name>

#3


0  

Generate scripts in SQL Server Management Studio from one database's table and run the generated script in another database. 如何将数据从一个数据库表复制到sql server中的另一个数据库现有表

从一个数据库的表生成SQL Server Management Studio中的脚本,并在另一个数据库中运行生成的脚本。

#4


0  

Broadly speaking:

 INSERT INTO [databaseName].[schemaName].[table2]
 SELECT * FROM [databaseName].[schemaName].[table1]

If you are more specific in your question, I can provide a more detailed answer.

如果您在问题中更具体,我可以提供更详细的答案。

#5


-1  

I suppose you want to copy data from all columns keeping the same order in two tables. If both tables exist in your database use

我想你想要从两个表中保存相同顺序的所有列中复制数据。如果您的数据库中存在两个表使用

insert into targetTable 
select * from sourceTable

If not, use

如果没有,请使用

select * into targetTable 
from sourceTable

In the second case, the targetTable will inherit the datatypes from the sourceTable (not the keys, indexes, etc..)

在第二种情况下,targetTable将继承sourceTable中的数据类型(而不是键,索引等)。

#1


0  

Try this ...

试试这个 ...

INSERT INTO DataBase2.dbo.table2
SELECT * FROM DataBase1.dbo.table1

#2


2  

insert into <target table name>(columns)
select columns 
from <source table name>

#3


0  

Generate scripts in SQL Server Management Studio from one database's table and run the generated script in another database. 如何将数据从一个数据库表复制到sql server中的另一个数据库现有表

从一个数据库的表生成SQL Server Management Studio中的脚本,并在另一个数据库中运行生成的脚本。

#4


0  

Broadly speaking:

 INSERT INTO [databaseName].[schemaName].[table2]
 SELECT * FROM [databaseName].[schemaName].[table1]

If you are more specific in your question, I can provide a more detailed answer.

如果您在问题中更具体,我可以提供更详细的答案。

#5


-1  

I suppose you want to copy data from all columns keeping the same order in two tables. If both tables exist in your database use

我想你想要从两个表中保存相同顺序的所有列中复制数据。如果您的数据库中存在两个表使用

insert into targetTable 
select * from sourceTable

If not, use

如果没有,请使用

select * into targetTable 
from sourceTable

In the second case, the targetTable will inherit the datatypes from the sourceTable (not the keys, indexes, etc..)

在第二种情况下,targetTable将继承sourceTable中的数据类型(而不是键,索引等)。