cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Databricks External Data SQL Server Connection Dirty Reads

wallco26
New Contributor II

I've connected a SQL Server database as an external connection in Unity Catalog. It looks like when I write SELECT queries to that connection I end up locking my tables on the SQL Server. Is there a way to query these tables using a "with (nolock)" command like I would inside SQL Server? I've done this in the past in Databricks by using a JDBC connection to the same server and adding "with (nolock)" to the right of my table name string.

4 REPLIES 4

Kaniz_Fatma
Community Manager
Community Manager

Hi @wallco26To avoid locking tables when querying SQL Server databases using Unity Catalog, you can pass the WITH (NOLOCK) Hint as an option when creating the foreign catalogue in Unity Catalog. 

wallco26
New Contributor II

Thanks Kaniz. How would I go about doing this? I don't see a hint option in the Connection UI or the Catalog UI.

Hi @wallco26 , 

If you can't find options on the UI, you can always use SQL syntax to create foreign catalog: 

CREATE FOREIGN CATALOG [IF NOT EXISTS] <catalog-name> USING CONNECTION <connection-name>

OPTIONS (database '<database-name>');

wallco26
New Contributor II

Thanks Slash - where would the "with (nolock)" command fall into the SQL Syntax...within the OPTIONS section? What would the specific command look like?

 

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group