如何将表值从一个数据库插入到另一个数据库? [英] How to insert table values from one database to another database?

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

问题描述

如果目标表已经存在,我想要一个查询将记录从一个表插入到另一个数据库中的另一个表,它应该将记录附加到表的末尾.

I want a query to insert records from one table to another table in a different database if the destination table already exists, it should append the records at the end of the table.

推荐答案

这个怎么样:

USE TargetDatabase
GO

INSERT INTO dbo.TargetTable(field1, field2, field3)
   SELECT field1, field2, field3
     FROM SourceDatabase.dbo.SourceTable
     WHERE (some condition)

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

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