I am using the RODBC package to query a column of text from a database. The database is built on Microsoft SQL Server 2008 R2. The column data type 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) ")
In SQL, I expect (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 causes this truncation and how to avoid it? Thanks!!
sql sql-server r
Ray
source share