如何在创建函数或存储过程时与外部数据库进行交互。 [英] How do I interact with external database while creating function or stored procedure.

查看:230
本文介绍了如何在创建函数或存储过程时与外部数据库进行交互。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据库'abc',我正在尝试编写需要与数据库'xyz'中的表进行交互的过程。我能做些什么。



我的尝试:



我有一个数据库'abc',我正在尝试编写需要与数据库'xyz'中的表进行交互的过程。我该怎么办。

解决方案

查看这篇文章的答案 sql server - 如何查询位于不同数据库中的表? [ ^ ]

基本上你只需要使用完全限定的表名。如果数据库位于不同的服务器上,那么您需要先将它们链接起来 - 链接服务器(数据库引擎) [ ^ ]


你必须使用表的3部分名称表示database1 = abc,database2 = xyz然后[abc]。[dbo]。[table1]和[xyz]。[dbo]。[table2]

I have a database 'abc' and i am trying to write procedure which requires to interact with table in database 'xyz'. What can i do.

What I have tried:

I have a database 'abc' and i am trying to write procedure which requires to interact with table in database 'xyz'. What can i do.

解决方案

See the answer to this post sql server - How do I query tables located in different database?[^]
Basically you just need to use the fully qualified table name. If the databases are on different servers then you will need to link them first - Linked Servers (Database Engine)[^]


you must use the 3 part name for tables means database1=abc,database2=xyz then [abc].[dbo].[table1] and [xyz].[dbo].[table2]


这篇关于如何在创建函数或存储过程时与外部数据库进行交互。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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