如何在sql 2012中将数据从一个数据库表插入另一个数据库表 [英] How to insert data from one database table to another database table in sql 2012

查看:99
本文介绍了如何在sql 2012中将数据从一个数据库表插入另一个数据库表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

如何将数据从一个数据库表插入另一个数据库表。

例如:

在db1中: -i有一些国家表和列是id,名称

在db2中:-i有一些国家表和列在id,名称

id是autogenerate value



如何将db2数据插入到db1。



以上示例仅供我们理解,但我的表包含15列所以怎么做,并有一列作为自动生成密钥



我尝试过:



i需要示例代码怎么做。

Hi to all,
How to insert data from one database table to another database table.
for example:
In db1 :-i have some country table and column is id,name
in db2 :-i have some country table and column in id,name
id is autogenerate value

how to insert db2 data to db1.

above example just for our understanding but my table contain 15 column so how to do that and have one column as autogenerate key

What I have tried:

i need example code how to do.

推荐答案

insert into db1.dbo.country (columnA, ColumnB)
Select columnA, columnB from db2.dbo.country


这篇关于如何在sql 2012中将数据从一个数据库表插入另一个数据库表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆