azureazure-sql-databaseazure-synapseazure-cosmosdb-gremlinapi

Azure Cosmos DB Gremlin API via Synapse Link using the serverless SQL pool


I am attempting to run queries on Azure Cosmos DB Gremlin API via Synapse Link using the serverless SQL pool, but I'm encountering an "error: A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - The specified network name is no longer available.) ".

 SELECT top 1 
   *
FROM OPENROWSET (
    'CosmosDB', 
    N'Account=cosbbbbbbbbiv01t;Database=bbbbb;key=bbbbbbbbbbbb==', 
    Graph1 
) AS q1

Solution

  • If you were getting a TCP error (like a timeout or connection failure) when using OPENROWSET in SQL Server or Azure Synapse, and adding the WITH clause resolved it — it's likely due to the way OPENROWSET interacts with external data sources. Here's the breakdown:
    ________________________________________
    ✅ Why Adding WITH (...) Fixes TCP Errors
    The WITH clause provides explicit schema definition and connection options, which helps SQL Server or Synapse correctly connect, parse, and stream the external data.
    Without it:
    •   SQL tries to auto-detect schema, which may trigger unnecessary or malformed network requests.
    •   The connection to the external source (e.g., Azure Storage, ADLS, Blob, etc.) might fail due to incomplete metadata or timeout while inferring schema.
    •   This can cause TCP-level issues like:
    o   TCP Provider: Error code 0x2746
    o   A connection attempt failed
    o   Timeout issues
    ________________________________________
    💡 Example Without WITH (can fail)
    SELECT * 
    FROM OPENROWSET(
        BULK 'https://storage.blob.core.windows.net/container/file.csv',
        FORMAT='CSV'
    ) AS rows
    ✅ Example With WITH (fixes errors)
    SELECT * 
    FROM OPENROWSET(
        BULK 'https://storage.blob.core.windows.net/container/file.csv',
        FORMAT='CSV',
        PARSER_VERSION='2.0'
    ) 
    WITH (
        Id INT,
        Name VARCHAR(100),
        Age INT
    ) AS rows
    The WITH clause helps:
    •   Predefine schema
    •   Speed up parsing
    •   Avoid ambiguous metadata guessing
    •   Prevent unnecessary round trips