1

I want to connect to a Linked Server in a MSSQL server instance using my NodeJS App. I have all the required credentials like the hostname, port, username, password, linked server name, server object name etc. I am using node-mssql in my NodeJS application but I noticed that they havent mentioned anything about connecting to anything else other than databases.

This is the structure of the Linked Server -

enter image description here

I want to access the tables in the MPI820 Database on the Linked Server. The path to access it is - Server Instance -> Server Objects -> Linked Servers -> AS400_SIT -> Catalogs -> MPI820 -> DB Table

On the internet also I am unable to find any article/tutorial/help to achieve this. If anyone has any knowledge or any helpful links about doing this or can share if and how they achieved this then all the help will be much much appreciated. Thankz in advance.

jarlh
  • 42,561
  • 8
  • 45
  • 63
  • Can you read data from SQL server 'local' databases? If yes, then create required pass-through views (or procedures) for linked server objects, configure permissions (maybe you should use stored credentials for linked server) and use those local views and procedures. – Arvo Mar 30 '20 at 12:56
  • From any database, try `select* from AS400_SIT.MPI820.POLSITDTA.AAAL`. BTW any activities through a linked server is a bad idea – Nick.Mc Mar 30 '20 at 12:59
  • More info on four part naming here https://www.ibm.com/support/pages/issuing-queries-using-microsoft-sql-server-query-analyzer-against-db2-udb-linked-server-using-oledb and here https://www.starquest.com/docs/Supportdocs/techStarSQL/StarSQLODBC/ThirdPartyApplications/SQ004_UsingLinkedServers.shtml – Nick.Mc Mar 30 '20 at 13:02
  • @Arvo yes I can CRUD data from local databases on that server. Connecting to server objects is the problem here. And the credentials given to me to access either a DB or a Server Object is strictly linked to that DB or Server Object. I cannot access anything else. And I dont have the admin privileges to create new credentials. But, in any case, do you have any links or something that I can take a look at to see how pass-through views/procedures are created and used? – Simple_Programmer Mar 30 '20 at 13:30
  • @Nick.McDermaid To connect to the instance and run the query structure that you suggested, I have to specify a DB name. And the node-mssql package uses a DB name to connect to the instance and its not accepting the server object name I am providing to it. – Simple_Programmer Mar 30 '20 at 13:34
  • `create view myschema.myview as select * from AS400_SIT.MPI820.POLSITDTA.AAAL` plus play with permisssions – Arvo Mar 30 '20 at 13:34
  • @Arvo I will try this and let you know. – Simple_Programmer Mar 30 '20 at 13:37
  • Connect to any dB. It doesn’t matter which db. – Nick.Mc Mar 30 '20 at 13:46
  • To clarify, connect to any database on the SQL Server (i.e. master) then run the query. – Nick.Mc Mar 31 '20 at 08:41

0 Answers0