How to Execute DROP VIEW Command in Synapse Notebook with SQL Serverless Pool Connection?

MulluriNivas-6816 80 Reputation points
2024-12-23T13:16:04.3133333+00:00

How to Connect Synapse Notebook to SQL Serverless Pool for Executing DROP VIEW Command?

I’m working with Azure Synapse Analytics and need to connect my Synapse Notebook to a SQL Serverless Pool to directly drop and create views. However, when I try running the DROP VIEW command in the notebook without explicitly setting up a connection, I get the following error:

[TABLE_OR_VIEW_NOT_FOUND]

The view does exist, but I can’t execute the command successfully. I couldn’t find any clear instructions on how to establish this connection within the notebook.

Could someone guide me on how to resolve this issue or set up the connection correctly? Any help would be greatly appreciated!

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,093 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Smaran Thoomu 18,710 Reputation points Microsoft Vendor
    2024-12-23T14:09:36.0466667+00:00

    Hi @MulluriNivas-6816

    Thank you for your question!

    It looks like the issue might be related to the connection setup between your Synapse Notebook and the SQL Serverless Pool. Here are some steps to verify and correct the connection:

    Verify the JDBC Driver and Connection String:

    Ensure you are using the correct JDBC driver and connection string for SQL Serverless Pool. Below is an example connection string that you can use in your notebook:

    server = '<serverName>-ondemand.sql.azuresynapse.net'  # Replace <serverName> with your Synapse workspace name
    port = 1433
    database = 'db'  # Replace 'db' with your database name
    
    jdbc_url = f"jdbc:sqlserver://{server}:{port};databaseName={database};encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30"
    

    Make sure:

    • The <serverName> matches your Synapse workspace name.
    • The database name (db) corresponds to the correct SQL Serverless Pool database.

    Set Up the Connection in Synapse Notebook:

    Ensure that your notebook is correctly configured to use this connection string when executing SQL commands. This might involve setting up a Spark session or specifying the driver explicitly if needed.

    Check for Required Drivers:

    Ensure the appropriate JDBC driver is installed and available in the environment. For Azure Synapse, use the Microsoft JDBC Driver for SQL Server. You can download the latest version from Microsoft JDBC Driver.

    Permissions and Pool Configuration:

    Make sure:

    • Your account has sufficient permissions to execute DROP VIEW.
    • You are connected to the correct database and SQL Serverless Pool.

    Hope this helps. Do let us know if you any further queries.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.