如何将数据从一个数据库的表复制到sql server 2005中的另一个相同数据库的表 [英] how to copy data from table of one database to another same database's table in sql server 2005

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

问题描述

实际上我正在为一家公司开发一个项目。所以我的客户希望今天的所有交易日期复制到包含所有交易的主数据库。

并且不想分享他的所有对他人的交易都要求今天约会。



所以我想把今天的数据复制到每天都有相同表格的主数据库。

所以PLZ尽快帮助我....

谢谢

解决方案





尝试这样,

  SELECT  *  INTO 表2  FROM 表1  WHERE  日期 = GETDATE()



请参阅此更多

HTTP://blog.sqlauthority的.com / 20 07/08/15 / sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table / [ ^ ]



希望它有效。






在另一个表中插入今日记录尝试以下查询

为此查询创建标记程序

 声明 vchrScript   nvarchar  (max)
set vchrScript = ' insert到Db2.dbo.table1(col1,col2,col3)(从Db1.dbo.table1中选择col1,col2,col3,其中colDate = getdate())'
执行 sp_executesql @ vchrScript





希望它有所帮助你

好​​运


伙计们,

我试了好几个小时终于找到了解决方案,

请在你的连接字符串中使用sa凭证或者为这两个数据库使用通用的用户凭证。

actually i am developing a project for a company.so my client wants that all the transaction of today date copy to main database that has all the transactions.
and don't want to share his all transaction to others expect today date .

so i want copy the data of today date to main database that has same tables day by day.
so plz help me as soon as possible....
thanks

解决方案

Hi,

try like this,,

SELECT * INTO Table2 FROM Table1 WHERE Date = GETDATE()


refer this for more
http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/[^]

hope it works.


Hi,

to insert todays records in another table try following query
create strored procedure for this Query

Declare vchrScript as nvarchar(max)
set vchrScript='insert into Db2.dbo.table1(col1,col2,col3)(select col1,col2,col3 from Db1.dbo.table1 where colDate=getdate())'
Execute sp_executesql @vchrScript



hope it help u
Best Luck


Guys,
I was trying this for hours finally found the solution for this,
please use sa credentials in your connection string or use a common user credential for both databases.


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

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