title: How to execute a stored procedure in Azure Databricks PySpark?
body: <p>I am able to execute a simple SQL statement using PySpark in Azure Databricks but I want to execute a stored procedure instead. Below is the PySpark code I tried.</p>
  
  <pre><code>#initialize pyspark
  import findspark
  findspark.init('C:\Spark\spark-2.4.5-bin-hadoop2.7')
  #import required modules
  from pyspark import SparkConf, SparkContext
  from pyspark.sql import SparkSession
  from pyspark.sql import *
  import pandas as pd
  
  #Create spark configuration object
  conf = SparkConf()
  conf.setMaster("local").setAppName("My app")
  #Create spark context and sparksession
  sc = SparkContext.getOrCreate(conf=conf)
  spark = SparkSession(sc)
  
  table = "dbo.test"
  #read table data into a spark dataframe
  jdbcDF = spark.read.format("jdbc") \
      .option("url", f"jdbc:sqlserver://localhost:1433;databaseName=Demo;integratedSecurity=true;") \
      .option("dbtable", table) \
      .option("driver", "com.microsoft.sqlserver.jdbc.SQLServerDriver") \
      .load()
  
  #show the data loaded into dataframe
  #jdbcDF.show()
  sqlQueries="execute testJoin"
  resultDF=spark.sql(sqlQueries)
  resultDF.show(resultDF.count(),False)
  </code></pre>
  
  <p>This doesn't work — how do I do it?</p>