[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


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?

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,
str(sqlFetch(lakes, 'testtest'))

Thank you for your time,

Curt Seeliger, Data Ranger
Raytheon Information Services - Contractor to ORD

	[[alternative HTML version deleted]]

R-help_at_r-project.org mailing list
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