<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Valid init script for installing ODBC Driver 18 for SQL Server to a job cluster in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/valid-init-script-for-installing-odbc-driver-18-for-sql-server/m-p/155072#M54179</link>
    <description>&lt;P&gt;I need to execute stored procedures in my notebook, to do that I created an init script that installs ODBC driver to my job cluster. But the script stops working after some time and I can't figure out why, so the cluster can't start. Can someone send me a valid script that installs ODBC driver to a job cluster? I can provide more information if needed.&lt;/P&gt;</description>
    <pubDate>Tue, 21 Apr 2026 11:35:48 GMT</pubDate>
    <dc:creator>bi_123</dc:creator>
    <dc:date>2026-04-21T11:35:48Z</dc:date>
    <item>
      <title>Valid init script for installing ODBC Driver 18 for SQL Server to a job cluster</title>
      <link>https://community.databricks.com/t5/data-engineering/valid-init-script-for-installing-odbc-driver-18-for-sql-server/m-p/155072#M54179</link>
      <description>&lt;P&gt;I need to execute stored procedures in my notebook, to do that I created an init script that installs ODBC driver to my job cluster. But the script stops working after some time and I can't figure out why, so the cluster can't start. Can someone send me a valid script that installs ODBC driver to a job cluster? I can provide more information if needed.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2026 11:35:48 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/valid-init-script-for-installing-odbc-driver-18-for-sql-server/m-p/155072#M54179</guid>
      <dc:creator>bi_123</dc:creator>
      <dc:date>2026-04-21T11:35:48Z</dc:date>
    </item>
    <item>
      <title>Re: Valid init script for installing ODBC Driver 18 for SQL Server to a job cluster</title>
      <link>https://community.databricks.com/t5/data-engineering/valid-init-script-for-installing-odbc-driver-18-for-sql-server/m-p/155081#M54184</link>
      <description>&lt;P&gt;Hello !&lt;/P&gt;&lt;P&gt;I think in your case you need to use a cluster scoped init script and install the MS repo explicitly before installing msodbcsql18&amp;nbsp; andfor standard or dedicated access mode they should be stored in a UC&amp;nbsp;volume. Don't forget that DBKS runtimes use ubuntu 22.04&amp;nbsp;so scripts hardcoded for older ubuntu versions often become flaky over time.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2026 12:27:31 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/valid-init-script-for-installing-odbc-driver-18-for-sql-server/m-p/155081#M54184</guid>
      <dc:creator>amirabedhiafi</dc:creator>
      <dc:date>2026-04-21T12:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: Valid init script for installing ODBC Driver 18 for SQL Server to a job cluster</title>
      <link>https://community.databricks.com/t5/data-engineering/valid-init-script-for-installing-odbc-driver-18-for-sql-server/m-p/155090#M54185</link>
      <description>&lt;P&gt;The job cluster I am using is standard access mode and I store the .sh script in a UC volume and access it in the job yaml. I tried using this bash script but I get this error&amp;nbsp;failed: Script exit status is non-zero. I can't find anything else explicitly stating the error.&amp;nbsp;&lt;BR /&gt;#!/bin/bash&lt;BR /&gt;# Download the Microsoft signing key&lt;BR /&gt;echo "Downloading Microsoft signing key..."&lt;BR /&gt;curl &lt;A href="https://packages.microsoft.com/keys/microsoft.asc" target="_blank"&gt;https://packages.microsoft.com/keys/microsoft.asc&lt;/A&gt; | sudo apt-key add -&lt;BR /&gt;# Add the Microsoft repository for ODBC Driver 18&lt;BR /&gt;echo "Adding Microsoft repository..."&lt;BR /&gt;curl &lt;A href="https://packages.microsoft.com/config/ubuntu/$(lsb_release" target="_blank"&gt;https://packages.microsoft.com/config/ubuntu/$(lsb_release&lt;/A&gt; -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list&lt;BR /&gt;# Update the package index&lt;BR /&gt;echo "Updating package index again..."&lt;BR /&gt;sudo apt-get update&lt;BR /&gt;# Install the ODBC Driver 18&lt;BR /&gt;echo "Installing ODBC Driver 18..."&lt;BR /&gt;sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18&lt;BR /&gt;# Install oDBC Driver Manager&lt;BR /&gt;# echo "Installing ODBC Driver manager ..."&lt;BR /&gt;sudo apt-get -y install unixodbc-dev&lt;BR /&gt;# Check if the driver is installed&lt;BR /&gt;echo "Checking installed driver..."&lt;BR /&gt;dpkg -L msodbcsql18&lt;BR /&gt;echo "ODBC Driver installation completed successfully."&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2026 13:45:04 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/valid-init-script-for-installing-odbc-driver-18-for-sql-server/m-p/155090#M54185</guid>
      <dc:creator>bi_123</dc:creator>
      <dc:date>2026-04-21T13:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: Valid init script for installing ODBC Driver 18 for SQL Server to a job cluster</title>
      <link>https://community.databricks.com/t5/data-engineering/valid-init-script-for-installing-odbc-driver-18-for-sql-server/m-p/155115#M54192</link>
      <description>&lt;P&gt;You don't need an &lt;STRONG&gt;ODBC driver inside a Databricks job cluster&lt;/STRONG&gt; to run stored procedures, and init scripts are fragile enough that they easily break cluster startup.&lt;/P&gt;
&lt;P&gt;Options:&lt;/P&gt;
&lt;HR /&gt;
&lt;H3&gt;Option 1 (Recommended): Use built-in JDBC / connectors instead of ODBC&lt;/H3&gt;
&lt;P&gt;For SQL Server and most RDBMS, Databricks already ships JDBC-based connectors; you can call stored procedures from notebooks without installing any OS-level driver. For example, SQL Server:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class="language-python"&gt;driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
host = "&amp;lt;server-host&amp;gt;"
port = "1433"
database = "&amp;lt;db-name&amp;gt;"
user = "&amp;lt;user&amp;gt;"
password = "&amp;lt;password&amp;gt;"

url = f"jdbc:sqlserver://{host}:{port};database={database}"

df = (spark.read
      .format("jdbc")
      .option("driver", driver)
      .option("url", url)
      .option("dbtable", "dbo.SomeTable")  # Or a view wrapping a stored proc
      .option("user", user)
      .option("password", password)
      .load())
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;On newer runtimes you can also use the &lt;CODE&gt;sqlserver&lt;/CODE&gt; data source or Lakehouse Federation / &lt;CODE&gt;remote_query&lt;/CODE&gt; to run native SQL (including &lt;CODE&gt;EXEC MyProc …&lt;/CODE&gt;) directly against SQL Server, again with no init script.&lt;BR /&gt;&lt;STRONG&gt;Recommendation:&lt;/STRONG&gt; If your goal is “run stored procedures from a notebook”, switch to these JDBC/federation options instead of ODBC; they’re supported, simpler, and far less brittle.&lt;/P&gt;
&lt;HR /&gt;
&lt;H3&gt;Option 2: Template cluster-scoped init script to install an ODBC driver&lt;/H3&gt;
&lt;P&gt;If you truly must use ODBC (for example, a tool library that only supports &lt;CODE&gt;pyodbc&lt;/CODE&gt;), use a &lt;STRONG&gt;cluster-scoped init script&lt;/STRONG&gt; stored in a &lt;STRONG&gt;Workspace file or UC Volume&lt;/STRONG&gt; (DBFS init scripts are end-of-life and can prevent clusters from starting).&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Example &lt;CODE&gt;install_odbc.sh&lt;/CODE&gt; (Ubuntu-style driver, adjust URL &amp;amp; bits for your vendor):&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class="language-bash"&gt;#!/bin/bash
set -euxo pipefail

LOG_DIR=/tmp/odbc-init
mkdir -p "$LOG_DIR"

echo "[$(date)] Starting ODBC init script" &amp;gt;&amp;gt; "$LOG_DIR/odbc-init.log"

# 1. System prerequisites
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
  unixodbc unixodbc-dev curl

# 2. Download &amp;amp; install your vendor ODBC driver (.deb example)
DRIVER_URL="https://&amp;lt;vendor&amp;gt;/path/to/driver_amd64.deb"
DRIVER_DEB="/tmp/driver.deb"

curl -fsSL "$DRIVER_URL" -o "$DRIVER_DEB"
dpkg -i "$DRIVER_DEB" || DEBIAN_FRONTEND=noninteractive apt-get install -f -y

# 3. (Optional) Register driver/DSN
# cat &amp;gt;&amp;gt; /etc/odbcinst.ini &amp;lt;&amp;lt;'EOF'
# [MyVendorDriver]
# Description=My DB ODBC Driver
# Driver=/opt/myvendor/lib/libmyodbc.so
# EOF
#
# cat &amp;gt;&amp;gt; /etc/odbc.ini &amp;lt;&amp;lt;'EOF'
# [MyVendorDSN]
# Driver=MyVendorDriver
# Server=&amp;lt;server&amp;gt;
# Database=&amp;lt;database&amp;gt;
# Port=&amp;lt;port&amp;gt;
# EOF

echo "[$(date)] Finished ODBC init script" &amp;gt;&amp;gt; "$LOG_DIR/odbc-init.log"
exit 0
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Key points so the cluster keeps starting:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Store the script at a supported path (for example &lt;CODE&gt;/Workspace/.../install_odbc.sh&lt;/CODE&gt; or &lt;CODE&gt;/Volumes/&amp;lt;cat&amp;gt;/&amp;lt;sch&amp;gt;/&amp;lt;vol&amp;gt;/install_odbc.sh&lt;/CODE&gt;) and configure it as a &lt;STRONG&gt;cluster-scoped init script&lt;/STRONG&gt; on the job’s compute.&lt;/LI&gt;
&lt;LI&gt;Keep it &lt;STRONG&gt;small (&amp;lt;64 KB)&lt;/STRONG&gt; and make sure it always exits 0 on success; any non-zero code causes the job cluster to fail to start.&lt;/LI&gt;
&lt;LI&gt;On &lt;STRONG&gt;Standard access mode&lt;/STRONG&gt; clusters, the script path must be &lt;STRONG&gt;allowlisted&lt;/STRONG&gt; by a metastore admin, or it will be blocked.&lt;/LI&gt;
&lt;LI&gt;If it “stops working after some time”, the usual culprits are:
&lt;UL&gt;
&lt;LI&gt;Script stored on DBFS root (now disallowed)&lt;/LI&gt;
&lt;LI&gt;Script path no longer on the allowlist after moving to Standard mode&lt;/LI&gt;
&lt;LI&gt;Upstream package URL changed and &lt;CODE&gt;curl&lt;/CODE&gt;/&lt;CODE&gt;apt-get&lt;/CODE&gt; now fails (check init logs)&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;You can inspect failures in &lt;CODE&gt;/databricks/init_scripts/...stdout.log&lt;/CODE&gt; or via cluster log delivery.&lt;/P&gt;
&lt;HR /&gt;
&lt;H3&gt;Option 3: Use Lakehouse Federation / &lt;CODE&gt;remote_query&lt;/CODE&gt; to execute procedures&lt;/H3&gt;
&lt;P&gt;For SQL Server and several other databases, you can create a Unity Catalog &lt;STRONG&gt;connection&lt;/STRONG&gt; and then use &lt;CODE&gt;remote_query&lt;/CODE&gt; to run the database’s native SQL (including stored procedures) from Databricks SQL or notebooks, again without any OS-level driver:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class="language-sql"&gt;SELECT *
FROM remote_query(
  'my_sqlserver_connection',
  database =&amp;gt; 'MyDb',
  query    =&amp;gt; 'EXEC dbo.MyStoredProc @Param1 = 42'
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This uses JDBC under the hood and is the strategic path for cross-system querying.&lt;/P&gt;
&lt;HR /&gt;
&lt;P&gt;&lt;STRONG&gt;My recommendation:&lt;/STRONG&gt;&lt;BR /&gt;Use &lt;STRONG&gt;Option 1 or 3 (JDBC / Lakehouse Federation / &lt;CODE&gt;remote_query&lt;/CODE&gt;)&lt;/STRONG&gt; instead of installing an ODBC driver on the job cluster. Only use Option 2 if you’re blocked by a hard dependency on ODBC, and in that case, adapt the template script above and double-check script location, allowlist, and init-script logs to understand why it started failing.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2026 16:12:11 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/valid-init-script-for-installing-odbc-driver-18-for-sql-server/m-p/155115#M54192</guid>
      <dc:creator>Lu_Wang_ENB_DBX</dc:creator>
      <dc:date>2026-04-21T16:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: Valid init script for installing ODBC Driver 18 for SQL Server to a job cluster</title>
      <link>https://community.databricks.com/t5/data-engineering/valid-init-script-for-installing-odbc-driver-18-for-sql-server/m-p/155120#M54193</link>
      <description>&lt;P&gt;What you did is very close the only things I’d fix first are the apt-key flow because it is deprecated and you need to add&amp;nbsp;set -euo pipefail&amp;nbsp;because right now the script can fail in the middle without giving you a useful stop point.&lt;/P&gt;&lt;P&gt;Also&amp;nbsp;init scripts run as root so sudo is not needed&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2026 17:34:18 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/valid-init-script-for-installing-odbc-driver-18-for-sql-server/m-p/155120#M54193</guid>
      <dc:creator>amirabedhiafi</dc:creator>
      <dc:date>2026-04-21T17:34:18Z</dc:date>
    </item>
  </channel>
</rss>

