如何在存储过程中编写连接字符串 [英] How to write connection string in Stored procedure
本文介绍了如何在存储过程中编写连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好b $ b
我需要将数据从一个服务器DB提取到其他服务器数据库。
我在想在插入行时使用以下合并语句将数据从一个服务器复制到另一个服务器。(因为我不能使用触发器)
Hi
I need to fetch the data from one server DB to other server DB.
I am thinking of using the following merge statement to copy data from one server to other when a row is inserted.(Since i cannot use triggers)
Merge into tbl3 as tab2
using(select * from Tbl1) as tab1
on tab1.id=tab2.id
when not matched then
insert values(tab1.id, tab1.Name, tab1.Country);
但这在单个数据库中工作正常。
请帮我使用存储过程从一个服务器获取最新行
but this works fine in single database.
Please help me to fetch latest row from one server to other using stored procedure
推荐答案
请参阅SQL Server帮助文件中的以下主题:
* OPENDATASOURCE(Transact-SQL)
示例:
See the following topic in the SQL Server Help file:
* OPENDATASOURCE (Transact-SQL)
Example:
SELECT * FROM
OPENDATASOURCE(
'SQLNCLI','Data Source=London\Payroll;Integrated Security=SSPI'
).AdventureWorks2012.HumanResources.Employee
另见文档:
* sp_addlinkedserver(Transact- SQL)
* sp_serveroption(Transact-SQL)
Also see documentation for:
* sp_addlinkedserver (Transact-SQL)
* sp_serveroption (Transact-SQL)
这篇关于如何在存储过程中编写连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文