我有这个使用SQL Server运行的经典ASP应用程序。我使用以下查询:
sql = "SELECT TOP 30 r.RMANumber, r.CompanyName, r.ContactName, r.Country, r.Phone, r.IssuanceDate, r.DateReceived, r.CreatedBy " & _
"FROM rma r " & _
"WHERE r.IssuanceDate >= '" & startDate & "' AND r.IssuanceDate <= '" & DateAdd("d", 1, CDate(endDate)) & "' AND r.RMAClosed = 'No' " & _
"ORDER BY IssuanceDate DESC"
我想在其中添加INNER JOIN
,但INNER JOIN
会在不同的数据库中查找。我可以这样做:
sql = "SELECT TOP 30 r.RMANumber, r.CompanyName, r.ContactName, r.Country, r.Phone, r.IssuanceDate, r.DateReceived, r.CreatedBy " & _
"FROM [database1].[dbo].[rma] r " & _
"INNER JOIN [database2].[dbo].[users] u " & _
答案 0 :(得分:1)
如果您的其他数据库位于另一台服务器中。输入服务器的IP地址,如下所示:
sql = "SELECT TOP 30 r.RMANumber, r.CompanyName, r.ContactName, r.Country, r.Phone, r.IssuanceDate, r.DateReceived, r.CreatedBy " & _
"FROM [database1].[dbo].[rma] r " & _
"INNER JOIN [ip address of other server here].[database2].[dbo].[users] u " & _
注意: 确保您已连接并且可以访问其他数据库所在的服务器。