A second Step into Machine Learning. How to read data in R language from SQL Server


Hi Guys,
I wish you an happy Easter!

Today we will do another little step into the Machine Learning.
Some weeks ago infact we talk about how to install Machine Learning services in SQL Server.
I suggest to read the post you can find here: From SQLServer to ML, a first little step into machine learning
This is because today we will see how to read data from SQL database with the R language.

Read data in R language

If you remember, in the previuos post we have enabled the execution of external scripts.
Infact we will use external scripts in order to read data from SQL Server.

The procedure sp_execute_external_script have some parameters that are:
  • The language in this case you must specify "R"
  • Command sent to R Runtime
  • The input_data_1query data result
  • Schema of the table returned

For the example below we will read data from our ORDTES table:

       
USE MASTER

EXECUTE sp_execute_external_script 
     @language = N'R'
    , @script = N'OutputDataSet <- InputDataSet;'
    , @input_data_1 = N'SELECT ID FROM ECO.DBO.ORDTES;'
WITH RESULT SETS((ID INT NOT NULL));     
 

The next step!

Now we have seen how to read data from a SQL Server Database.
The next step will be more and more interesting.
We will see how to create and train a model.

I hope to see you soon for the next parts!
Luca

Luca Biondi @ SQLServerPerformance blog 2020! 

















Comments

  1. Three are normally modest Ralph Lauren accessible available to be purchased every last time you wish to purchase. how to invest in bitcoin cash online

    ReplyDelete

Post a Comment

I Post più popolari

SQL Server, execution plan and the lazy spool (clearly explained)

SQL Server, datetime vs. datetime2

La clausola NOLOCK. Approfondiamo e facciamo chiarezza!