Search code examples
sqlrrodbcvsql

How to delete 1st column in SQL Database using R


This is a simple example
Basket                                        

rownames fruit       quantities     
1        apple           3
2        orange          4
3        tomatoes        6
4        watermelon      7
5        durian          8

How do I remove the rownames using R in SQL, sorry I am new to R and SQL.


Solution

  • Note that I cannot test this on my machine.

    You can try setting rownames=FALSE when you sqlFetch the table. That may solve your problem.

    But, to solve the problem in the title, you can do:

    BasketDF<-sqlFetch(ch,"Basket")
    NewBasket<-BasketDF[,-1]
    sqlUpdate(ch,NewBasket,"Basket")