[R] RODBC changes data types when reading from MS SQL Server 2005 -- How to fix?

From: <Seeliger.Curt_at_epamail.epa.gov>
Date: Tue, 17 Mar 2009 12:12:15 -0700


Folks,

As reproduced in the code below, our data is being transformed during the sqlFetch() operation. This has apparently been an issue since 2002. Are there any ways for correctly reading data from MS SQL Server 2005? Why does RODBC ignore the type information supplied by SQL Server?

require(RODBC)
lakes <- odbcConnect('Lakes',uid='cseelige') tt <- data.frame('a'='1234', 'b'='5678', 'c'=123.456, stringsAsFactors=FALSE)
sqlSave(lakes, tt, tablename='testtest', verbose=FALSE, safer=FALSE, test=FALSE, append=FALSE, fast=FALSE, rownames=FALSE)

# This shows the columns exist as varchar, varchar, float on the server
sqlColumns(lakes, 'testtest')

# This shows the columns are fetched as int, int, num instead of chr, chr,
num.
str(sqlFetch(lakes, 'testtest'))

Thank you for your time,
cur

-- 
Curt Seeliger, Data Ranger
Raytheon Information Services - Contractor to ORD
seeliger.curt_at_epa.gov
541/754-4638

	[[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.
Received on Tue 17 Mar 2009 - 18:15:32 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 17 Mar 2009 - 19:31:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive