-
Notifications
You must be signed in to change notification settings - Fork 0
/
sql_server.R
30 lines (23 loc) · 1.29 KB
/
sql_server.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#Connection options to SQL Server databases
con <- DBI::dbConnect(odbc::odbc(),
Driver = "SQL Server",
Server = "AARON-SIMUMBA\\SQLEXPRESS",
Database = "AdventureWorks2017",
Port = 1433,
UID = "rstudioconnect",
PWD = .rs.askForSecret(name ="AARON-SIMUMBA\\SQLEXPRESS",
title = "Enter Password",
prompt = "Database Password:"))
con <- DBI::dbConnect(odbc::odbc(),
Driver = "SQL Server",
Server = "AARON-SIMUMBA\\SQLEXPRESS",
Database = "AdventureWorks2017",
Port = 1433,
UID = rstudioapi::askForPassword("Database user"),
PWD = rstudioapi::askForPassword("Database password"))
library(RODBC)
conn <- RODBC::odbcDriverConnect('driver={SQL Server};
server=AARON-SIMUMBA\\SQLEXPRESS;
database=AdventureWorks2017;
trusted_connection=true')
data <- sqlQuery(conn, "SELECT * FROM Production.TransactionHistoryArchive;")