Since I struggled a bit with this one and couldn’t find a good online source with simple steps, here it is.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Run the following code in SSMS to create the linked server. This assumes a PostgreSQL instance on the local machine (hence localhost):
EXEC master.dbo.sp_addlinkedserver @server = N’POSTGRESQL’, @srvproduct=N’Microsoft OLE DB Provider for ODBC Driver’, @provider=N’MSDASQL’, @datasrc=’PostgreSQL’, @location=’localhost’, @catalog=’public’
Run the following code in SSMS to create a login mapping for the linked server:
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N’POSTGRESQL’, @useself=N’False’, @locallogin=NULL, @rmtuser=”, @rmtpassword=”
Issue statements such as:
SELECT * FROM OpenQuery(POSTGRESQL, ‘select my_column from my_table limit 10’)
I had to use the double-quote