title: Establish Microsoft SQL Server Connection with R/RStudio
body: <p>I am trying to connect R with Microsoft SQL server. I have used Toad for SQL Server  6.8 so far for my queries. However, for some other analysis (which can be easily performed in R) I want to connect database with R. </p>
  
  <p>I have tried R function "dbconnect" with providing server name and database name. See query below:</p>
  
  <pre><code>   odbc_con &lt;- dbConnect(odbc::odbc(),
                    Driver = "SQL Server",
                    Server = "xxxxx",
                    Database = "yyyyy", 
                    Uid = 'US\dhrdesai',
                    Pwd = rstudioapi::askForPassword("Database password"),
                    Port = 1433) 
  </code></pre>
  
  <p>However, I got following errors:</p>
  
  <blockquote>
    <p>Error: nanodbc/nanodbc.cpp:950: IM002: [Microsoft][ODBC Driver
    Manager] Data source name not found and no default driver specified</p>
  </blockquote>
  
  <p>and </p>
  
  <blockquote>
    <p>Error: unexpected ')' in "                      Port = 1433)"</p>
  </blockquote>
  
  <p>Have anyone faced the same or know any other way to connect R with SQL server. </p>