[R] Connection to Microsoft SQL Server

David Scott d.scott at auckland.ac.nz
Tue May 19 01:02:52 CEST 2009


On Mon, 18 May 2009, Uwe Ligges wrote:

>
>
> Meenu Sahi wrote:
>> Dear Users
>> I am new to R. I'm trying to make a connection to Microsoft SQL Server via
>> R.
>> How can I find the correct syntax to make the connection? The Help pdf file
>> has an example for mySql but there's isnt much on SQL Server.
>> Please help.
>> I am trying the following code
>> library(RODBC)
>> con<-odbcConnect(dbname,hostname)
>> How do I specify the driver,userid,password etc?
>
> Well, you specify the DSN and other details in your Windows settings 
> (somewhere within the control panel) - given your OS is Windows?
> If you make a call to connect to that DSN, you will be asked for username and 
> password given you haven't specified it with the DSN in your Windows 
> settings.
>
> Uwe Ligges
>

The process of setting up the DSN name etc for Windows (albeit for MySQL, 
but the change for SQL Server is pretty obvious) is given in the document:

http://www.stat.auckland.ac.nz/~dscott/779/UsingMySQLAndODBC.pdf

David Scott




>
>> Many thanks for your help!
>> 
>> Me.
>>
>> 	[[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.
>
> ______________________________________________
> 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.
>

_________________________________________________________________
David Scott	Department of Statistics
 		The University of Auckland, PB 92019
 		Auckland 1142,    NEW ZEALAND
Phone: +64 9 373 7599 ext 85055		Fax: +64 9 373 7018
Email:	d.scott at auckland.ac.nz

Graduate Officer, Department of Statistics
Director of Consulting, Department of Statistics




More information about the R-help mailing list