我可以在 Visual Studio 中一起使用不同的数据连接吗?

发布于 2024-09-12 08:08:15 字数 243 浏览 0 评论 0原文

是否可以在 Visual Studio 中使用两个或多个数据连接并在单个查询中使用它们,就像我们在 SQL Server Management Studio 中所做的那样(同时使用 MySQL 和 MSSQL)?

例如

SELECT * INTO testMySQL.dbo.shoutbox
FROM openquery(MYSQL, 'SELECT * FROM tigerdb.shoutbox')

Is it possible to use two or more data connections in Visual Studio and use them in a single query, like we can do in SQL server management Studio (while we use MySQL and MSSQL at the same time)?

E.g.

SELECT * INTO testMySQL.dbo.shoutbox
FROM openquery(MYSQL, 'SELECT * FROM tigerdb.shoutbox')

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

望她远 2024-09-19 08:08:15

如果您使用 Microsoft SQL Server 和 MySQL,那么您可以使用 Microsoft SQL Server 链接服务器来完成此操作。链接服务器是通过 OLEDB 链接的服务器。该链接服务器将允许您从 SQL Server 连接到 MySQL 数据库并运行远程查询。

示例

SELECT * from MyLinkedServer.[Database].[Schema].TableName  T1
INNER JOIN MYSQLSERVER.DATABASE.DBO.TABLENAME T2 ON T1.PK = T2.PK

SELECT * FROM OPENQUERY([NameOfLinkedSERVER], 'SELECT * FROM TABLENAME') T1
INNER JOIN MYSQLSERVER.DATABASE.DBO.TABLENAME T2 ON T1.PK = T2.PK

If your using Microsoft SQL Server and MySQL, then you can use Microsoft SQL Server Linked Server to accomplish this. A Linked Server is a server linked via OLEDB. This linked server will allow you to connect to the MySQL database from SQL Server and run remote queries.

Example

SELECT * from MyLinkedServer.[Database].[Schema].TableName  T1
INNER JOIN MYSQLSERVER.DATABASE.DBO.TABLENAME T2 ON T1.PK = T2.PK

OR

SELECT * FROM OPENQUERY([NameOfLinkedSERVER], 'SELECT * FROM TABLENAME') T1
INNER JOIN MYSQLSERVER.DATABASE.DBO.TABLENAME T2 ON T1.PK = T2.PK
魄砕の薆 2024-09-19 08:08:15

不(据我所知)。但是您也许可以从 web.config 解构连接字符串以获取数据库位置,并从那里重新创建您的 sql(在 SP 中)?

No (AFAIK). But you could perhaps deconstruct the connectionstring from your web.config to get the db location, and re-create your sql (in a SP) from there?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文