B4J Question how to connect to a linked sqlserver server

Yoldi

Member
Hi.
I need to connect to a Sql server that has a linked server where is the table I need.
it is possible to do it with b4j the
driver net.sourceforge.jtds.jdbc.Driver and the jdbcsql library.

Does anyone have a connection example?

Thanks in advance
 

Jorge M A

Well-Known Member
Licensed User
Longtime User
not to the link server database.
You don't need to do anything to connect to the " linked server".
Once connected to your main server (I guess that's why Erel's ask you), assuming everything is correctly configured on your server, what you must change are your queries, with OPENQUERY, indicating the name of the linked server and your query sentence.

SQL:
Dim RS As ResultSet = SQL.ExecQuery("SELECT * FROM OPENQUERY([linkedServerName], 'SELECT * FROM {linkedDB}.{schema}.{table}')")

--eg:
Dim RS As ResultSet = SQL.ExecQuery("SELECT * FROM OPENQUERY([toshiba], 'SELECT Name FROM Sales.dbo.Customer')")
 
Upvote 0
Top