myconn<-odbcConnect("testdata")
sql.select<-paste("select UNIT_ID from UNITS where (UNIT_TYPE='",unit,"'
and COMMUNITY='",property,"')",sep="")

unit_ids<-sqlQuery(myconn,sql.select,as.is=TRUE)

This should works if myconn and sql.select are defined properly

Andrija
On Jun 7, 2013 9:58 PM, "Sneha Bishnoi" <sneha.bish...@gmail.com> wrote:

> tried as.is ,gives an error,
>
> [1] "01000 10054 [Microsoft][ODBC SQL Server
> Driver][DBNETLIB]ConnectionWrite (send())."
> [2] "[RODBC] ERROR: Could not SQLExecDirect 'select UNIT_ID from UNITS
> where (UNIT_TYPE='1X1' and COMMUNITY='SAN1193')'"
>
>
> On Fri, Jun 7, 2013 at 3:21 PM, andrija djurovic <djandr...@gmail.com>wrote:
>
>> ?sqlQuery
>> as.is - argument
>> Andrija
>> On Jun 7, 2013 9:10 PM, "Sneha Bishnoi" <sneha.bish...@gmail.com> wrote:
>>
>>> Hey all!
>>>
>>> I am trying to select a bunch of id's  (data type -character) from a
>>> table
>>> and store them in a variable in R
>>> But when i do this, it automatically truncates the leading zero's in id's
>>> even though they are of character type.
>>>
>>> code is :-
>>>
>>> >myconn<-odbcConnect("testdata")
>>> >sql.select<-paste("select UNIT_ID from UNITS where (UNIT_TYPE='",unit,"'
>>> and COMMUNITY='",property,"')",sep="")
>>> > unit_ids<-sqlQuery(myconn,sql.select)
>>> >print(unit_ids)
>>> is there anyway i can retain the UNIT_ID's as they are.
>>>
>>> Thanks!
>>> Sneha
>>>
>>>         [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> R-help@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.
>>>
>>
>
>
> --
> Sneha Bishnoi
> +14047235469
> H. Milton Stewart School of Industrial &  Systems Engineering
> Georgia Tech
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to