[R] Reading SQL Server Tables using RODBC

pfruin paul_fruin at capitaliq.com
Fri Dec 10 00:07:34 CET 2010



Paul Miller wrote:
> 
> 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
>  
>  
> Hi Paul M,
> 
>  I had the same problem, and based on your question & the piece that you
> got to work I was able to figure the rest of it out.  Here's how I got it
> to work:
> 
> channel <- odbcDriverConnect("driver=SQL Server;
> server=Fred";uid=pmiller;pwd=password")
> 
> and that makes the connection without having to manually type in the uid &
> pwd via the dialog box.
> 
> Hope that helps you, and thanks for helping me figure out the first half!
> 
> Paul F
> 
>  
> 
> 
>       __________________________________________________________________
> Looking for the perfect gift? Give the gift of Flickr! 
> 
> 
> 	[[alternative HTML version deleted]]
> 
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: http://r.789695.n4.nabble.com/Reading-SQL-Server-Tables-using-RODBC-tp1690973p3081141.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list