I am using the RODBC
package to query a text column from a database. The database is built on Microsoft SQL Server 2008 R2. The data type of the column in SQL is nvarchar(max)
.
However, when I run:
# Set up ODBC connection to CCWEB5 production server
# Note: default database is set to "CCSalary"
ccweb5.prod <- odbcConnect("ccweb5")
# Read in some job ad text
job.text <- sqlQuery(ccweb5.prod,"
SELECT TOP 100
ja.JobTitle,
ja.JobText as 'JobText',
LEN(ja.JobText) as 'JobTextLength'
FROM JobStore.dbo.JobAd as ja (NOLOCK)
")
Within SQL, I am expecting (for the top row):
JobTitle JobText JobTextLength
IT Field Service Technician <text goes here...> 2742
However, when I do: nchar(as.character(job.text[1,2]))
It returns: 255.
So my question is, what is causing this truncation and how do I avoid it? Thanks!!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…