azure-synapseazure-synapse-analyticsazure-notebooks

How to Connect Synapse Notebook to SQL Serverless Pool


I'm working with Azure Synapse Analytics and I need to connect my Synapse Notebook to my SQL Serverless Pool to drop and create views directly within the notebook. However, when I try to run the DROP VIEW command within the notebook without explicitly establishing a connection, I receive the following error:

[TABLE_OR_VIEW_NOT_FOUND]

Even though the view does exist, I cannot seem to execute the command successfully. I have tried searching for solutions on how to establish the connection within the notebook but couldn't find any relevant information.

Any help or guidance would be greatly appreciated!


Solution

  • Please check which Driver you are using to connect.

    your_connection_string = "Driver={ODBC Driver 17 for SQL Server};Server=tcp:<your-synapse-workspace>.sql.azuresynapse.net,1433;Database=<database-name>;Uid=<username>;Pwd=<password>;Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;"
    
    server = '<serverName>-ondemand.sql.azuresynapse.net'
    Port = 1433
    Database = "db"
    jdbcUrl = f"jdbc:sqlserver://{server}:{Port};databaseName={Database};encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30"
    

    if you provide your sample code we can discuss better.