OHDSI Home | Forums | Wiki | Github

How to use DatabaseConnector::createConnectionDetails for sql server to connect to the right database


(MB) #1

Hi all,

I’m running the following commands in rstudio and got the error below:
Error: Error executing SQL:
com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name ‘cdm.care_site’.

There are multiple databases under the server xxxxxxxx. How do i connect to the database I want in the sql server?

library(Achilles)
connectionD <- DatabaseConnector::createConnectionDetails(dbms = “sql server”,
server = “xxxxxxxx”

)

validateSchema(connectionDetails = connectionD,
cdmDatabaseSchema = “cdm”,
resultsDatabaseSchema = “results”,
cdmVersion = 5.3,
runCostAnalysis = TRUE,
outputFolder = “output”,
sqlOnly = FALSE)

Thanks!


(Roger Carlson) #2

Add the database name to the schema

cdmDatabaseSchema <- “databasename.cdm” # the fully qualified database schema name of the CDM
resultsDatabaseSchema <- “databasename.results” # the fully qualified database schema name of the results schema (that you can write to)


(MB) #3

Thanks Roger! Add the database name in the schema works!


t