Connect SQL Server to HubSpot CRM

We're currently developing a HubSpot CRM ODBC driver, and so thought we'd share how you can use this connector to work with your HubSpot CRM data in SQL Server.

Work With HubSpot CRM Data by using a Linked Server

  1. In Microsoft SQL Server Management Studio, connect to the SQL Server instance you want to create the linked server against.

    You need to log on with an account that is a member of the SQL Server sysadmin fixed server role to create a linked server.

  2. Right-click Server Objects. From the pop-up menu choose New > Linked Server.
  3. In the Linked server box, type "HubSpot".
  4. From the Provider list, choose Microsoft OLE DB Provider for ODBC Drivers.
  5. In the Data source box, type the name of a HubSpot CRM ODBC data source, and then choose OK.

    SQL Server verifies the linked server by testing the connection.

    • If you get the error "Specified driver could not be loaded due to system error 126: The specified module could not be found", choose Yes when prompted whether to keep the linked server. You need to restart your SQL Server instance before you can use the linked server. If SQL Server was already running when you installed the HubSpot CRM ODBC driver, it will not have the latest version of the System PATH environment variable. The HubSpot CRM ODBC driver Setup program adds entries for the driver to the System PATH. Restarting the instance makes these changes available to SQL Server, allowing it to load the HubSpot CRM ODBC driver.
    • If you made a mistake when specifying the HubSpot CRM ODBC data source, you get the error "Data source name not found and no default driver specified. If you get this error, choose No when prompted whether to keep the linked server and edit the value in the Data source box.
  6. You can query your HubSpot CRM data either by using a:
    • Four part table name in a distributed query.

      A four part table name has the format:

      server_name.[database_name].[schema_name].table_name.

      Even though with HubSpot CRM there is no database or schema, the Easysoft ODBC-HubSpot CRM Driver returns a "dummy" value for both identifiers, because some ODBC applications expect there to be a database and a schema. The database that the driver returns is HB. The schema that the driver returns is DBO. Include thse identifiers in your SQL statements. For example:

      SELECT * FROM HUBSPOT.HB.DBO.MyTable
      

      The capitalisation of the table name must be the same as it is in HubSpot CRM. For example, the following query is invalid:

      SELECT * FROM HUBSPOT.HB.DBO.MYTABLE
      

      To check the capitalisation of the HubSpot CRM tables (objects), run:

      EXEC sp_tables_ex @table_server = 'HUBSPOT'
      
    • Pass-through query in an OPENQUERY function. For example:
      SELECT * FROM OPENQUERY(HUBSPOT, 'SELECT * FROM MYTABLE')
      

      SQL Server sends pass-through queries as uninterpreted query strings to the HubSpot CRM ODBC driver. This means that SQL Server does not apply any kind of logic to the query or try to estimate what that query will do.