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

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

问题描述

我要查询从一个表中插入记录到另一个表在不同的数据库中,如果目标表已经存在,它应该在表的末尾追加记录。请帮帮我。提前致谢。

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

推荐答案

这个怎么样:

USE TargetDatabase
GO

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

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

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