[R] Reading SQL Server Tables using RODBC

Bos, Roger roger.bos at rothschild.com
Thu Mar 25 18:04:39 CET 2010


Paul,

I have never tried odbcDriverConnect, but I can tell you how I connect to my SQL Server 2005 db.  I create a DNS entry using "odbcad32" (use start>run).  You can specify everything there and test the connection.  Once that tests okay, just use the following:

library(RODBC)
xf <- odbcConnect("dns entry name", "sql username", "sql user password")

HTH,

Roger


 

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Paul Miller
Sent: Thursday, March 25, 2010 12:47 PM
To: r-help at r-project.org
Subject: [R] Reading SQL Server Tables using RODBC

Hello Everyone,
 
I'm still quite new to R and am having trouble reading SQL Server Tables using RODBC. I've looked though the RODBC documentation as well as material I found online and in the book "Data Manipulation with R," but I just can't quite seem to get things to work.
 
Right now, I have code that looks something like:
 
channel <- odbcDriverConnect
("Driver=SQL Server;
Server=Fred; Connection=xx.x.x.xxx
Database=mydatabasename;
uid=pmiller; pwd=password;
Trusted_Connection=FALSE;")
 
When I run this code, I get the following error:
 
[RODBC] ERROR: state IM002, code 0, message [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
 
I do seem to be able to make a connection if I use:
 
channel <- odbcDriverConnect("driver=SQL Server; server=Fred")
 
Here, I haven't specified enough information but am allowed to do so subsequently using the SQL Server Login.
 
Can anyone show me how to rewrite the code above to make the connection I need without using the SQL Server Login?
 
Thanks,
 
Paul
 
 
 


      __________________________________________________________________
Looking for the perfect gift? Give the gift of Flickr! 


	[[alternative HTML version deleted]]
***************************************************************

This message is for the named person's use only. It may\...{{dropped:20}}



More information about the R-help mailing list