[R] Help on R functions

vikrant vikrant.shimpi at tcs.com
Tue Feb 9 13:10:46 CET 2010

Dear R Experts,
I have written a following function :-

myfunction<- function(servername,dbname,dbtablename){
channel <- odbcDriverConnect("driver=SQL Server;server=servername")
initdata<- sqlQuery(channel,paste("select * from  dbname ..  dbtablename"))
I have written this function which has input  parameters like servername
,dbname and dbtable to connect to Ms SQL server 2005 and get data from the
Now when I run this function using the following command


The variable initdata should contain all the data. But it does not contain
any data and dim(initdata)) is NULL.

I dont know how to pass the strings as parameters  in the function. Do I
have done this correctly?

If I run the same commands directly from the command line I get the expected

channel <- odbcDriverConnect("driver=SQL Server;server=01wh155073")
initdata<- sqlQuery(channel,paste("select * from  test_DB .. 

Then the initdata contains the data in the table "test_vikrant". My question
is there a way to write above in a function which contains the above
Please Help me...
View this message in context: http://n4.nabble.com/Help-on-R-functions-tp1474342p1474342.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list