Khet_Mng
Khet_Mng

Reputation: 79

How to connect R to SQL Azure?

I have two databases in Azure and each has 5 tables. I can perform data wrangling inside Azure using Kusto but I would rather prefer using RStudio. I wish to connect R with Azure such that I can run a script in R and return results without importing the actual datasets.

Please help, where do I start? I have zero knowledge of such connections.

Thank you in advance.

Upvotes: 1

Views: 1421

Answers (1)

AnuragSharma-MSFT
AnuragSharma-MSFT

Reputation: 692

Assuming you have already installed R and RStudio. Please follow below steps:

  1. Open ODBC Data Source through Start Window and Add a User Data Source under 'User DSN' as below. Follow through the next buttons until finish and test the connections. enter image description here

  2. Go to RStudio and create new connection, you should see the Data Source added in above step. You should see the connection and table listed under Azure Sql Database that you connected with. enter image description here

  3. Run the query like below in Console: dbGetQuery(con, "SELECT * from dbo.xxxx")

  4. You should be able to see the result set accordingly. You can play with queries in the way you want.

Upvotes: 1

Related Questions