Create table on SQL server with SparkR

46 Views Asked by At

From R notebook on Databricks I would like to create a table on SQL server. I am able to read SQL tables with the following:

library('magrittr')
library('SparkR')
    conn =  "jdbc:sqlserver://someconnection.windows.net:1433;database=some_db;user=user_name;password=user_password"
      
    data = SparkR::read.jdbc(conn, "(select top 100 * from TableA) as result") %>% SparkR::collect()

However, if I try something like this:

data = SparkR::read.jdbc(conn, "(CREATE TABLE TableA (PersonID int,
    LastName varchar(255))) as result") 

It does not work, it returns

Error : Error in jdbc : com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near the keyword 'CREATE'.

Any thoughts?

0

There are 0 best solutions below