R in SQL Server: Output data frame into a table
<p>This probably has a simple answer but I cannot figure it out as I'm still getting a hang of working with R in SQL Server. I have a piece of code that reads in data from a SQL Server table, executes in R and returns a data frame.</p>
<pre><code>execute sp_execute_external_script
    @language=N'R',
    @script=N'inp_dat=InputDataSet
    inp_dat$NewCol=max(inp_dat$col1,inp_dat$col2)
    new_dat=inp_dat
    OutputDataSet=new_dat'
    @input_data_1=N'select * from IM_COMP_TEST_SQL2016.dbo.temp_table';
</code></pre>
<p>I want to insert new_dat into a SQL Server table (<code>select * into new_table from new_dat</code>). How do I go about this?</p>