title: Query sql server table in azure databricks
body: <p>I am using the below code to query a sql server table <strong>hr.employee</strong> in my azure sql server database using azure databricks. I am new to spark sql and trying to learn the nuances one step at a time.</p>
  <p><strong>Azure Databricks:</strong></p>
  <pre><code>%scala
  val jdbcHostname = dbutils.widgets.get(&quot;hostName&quot;)
  val jdbcPort = 1433
  val jdbcDatabase = dbutils.widgets.get(&quot;database&quot;)
  val jdbcUrl = s&quot;jdbc:sqlserver://${jdbcHostname}:${jdbcPort};database=${jdbcDatabase}&quot;
  
  import java.util.Properties
  val connectionProperties = new Properties()
   
  connectionProperties.put(&quot;user&quot;, s&quot;${jdbcUsername}&quot;)
  connectionProperties.put(&quot;password&quot;, s&quot;${jdbcPassword}&quot;)
  
  %scala
  val driverClass = &quot;com.microsoft.sqlserver.jdbc.SQLServerDriver&quot;
  connectionProperties.setProperty(&quot;Driver&quot;, driverClass)
  
  %scala
  val employee = spark.read.jdbc(jdbcUrl, &quot;hr.Employee&quot;, connectionProperties)
  
  %scala
  spark.sql(&quot;select * from employee&quot;) 
  
  %sql
  select * from employee
  
  employee.select(&quot;col1&quot;,&quot;col2&quot;).show()
  </code></pre>
  <p>I get the below error. Not sure what wrong am I doing. Tried a couple of variations as well and no luck so far.</p>
  <p><strong>Error:</strong></p>
  <pre><code>';' expected but integer literal found.
  
  command-922779590419509:26: error: not found: value %
  %sql
  
  command-922779590419509:27: error: not found: value select
  select * from employee
  
  command-922779590419509:27: error: not found: value from
  select * from employee
  
  command-922779590419509:16: error: not found: value %
  %scala
  </code></pre>