0

We have a UNIX machine which includes R engine on it and installed SQL Server ODBC Driver 11.

We need to connect R to SQL Server. SQL Server currently works on another machine, so we tried to connect R to SQL Server with the code below.

library(RODBC)
dbhandle <- odbcDriverConnect('driver=ODBC Driver 11 for SQL Server;server=10.XXX.XX.XX:1663;')

But getting that error:

Warning messages: 1: In odbcDriverConnect("driver=ODBC Driver 11 for SQL Server;server=10.XXX.XX.XX:1663;") :

[RODBC] ERROR: state HYT00, code 0, message [unixODBC][Microsoft][ODBC Driver 11 for SQL Server]Login timeout expired 2: In odbcDriverConnect("driver=ODBC Driver 11 for SQL Server;server=10.XXX.XX.XX:1663;") :

[RODBC] ERROR: state 08001, code 87, message [unixODBC][Microsoft][ODBC Driver 11 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. 3: In odbcDriverConnect("driver=ODBC Driver 11 for SQL Server;server=10.XXX.XX.XX:1663;") :

[RODBC] ERROR: state 08001, code 87, message [unixODBC][Microsoft][ODBC Driver 11 for SQL Server]SQL Server Network Interfaces: Connection string is not valid [87]. 4: In odbcDriverConnect("driver=ODBC Driver 11 for SQL Server;server=10.XXX.XX.XX:1663;") : ODBC connection failed

If I run telnet to SQL Server from UNIX machine, it works perfectly. I mean there is a healthy connection between these two machine.

How can we connect R to SQL Server without using DSN?

asked Mar 9, 2016 at 9:24
4
  • Please don't cross-post between SE sites stackoverflow.com/questions/35868420/… Commented Mar 9, 2016 at 10:56
  • Why? @MarkSinkinson Commented Mar 9, 2016 at 12:43
  • Because that's the general rule of Stack Exchange DBA.stackexchange.com/help/on-topic Commented Mar 9, 2016 at 12:47
  • OK thanks for information. @MarkSinkinson I will obey this rule next time. Commented Mar 9, 2016 at 12:57

2 Answers 2

1

I changed delimiter which between server and port from : to , . It fixed my problem.

dbhandle <- odbcDriverConnect('driver=ODBC Driver 11 for SQL Server;server=10.XXX.XX.XX,1663;')
answered Mar 11, 2016 at 7:16
0

Connection string is not valid is the key error message there, I think.

Try:

dbconnection <- odbcDriverConnect("Driver=ODBC Driver 11 for SQL Server;
 Server=10.XXX.XX.XX:1663; Database=YOURDBNAME; 
 Uid=USERID; Pwd=PASSWORD")
answered Mar 9, 2016 at 10:47
1
  • Nothing changed @Phil Commented Mar 9, 2016 at 10:53

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.