# Recommended Synchronization SQL - From HubSpot to Database

This section gives guidelines on how to better synchronized data from HubSpot to ERP with some best practices. The names of the properties on both ERP and HubSpot are a suggestion, we suggest to customized properties according to your specific needs.

Create a [new table](https://learn.microsoft.com/en-us/sql/relational-databases/tables/create-tables-database-engine?view=sql-server-ver16) for extract companies HubSpot data to be passed to ERP, below an example of query for create the table.

```sql
USE [ERPBridge]
GO

/****** Object:  Table [dbo].[T_Companies] ******/

CREATE TABLE [dbo].[T_Companies](
	[ERPCode] [nvarchar](max) NULL,
	[CompanyName] [nvarchar](max) NULL,
	[StreetAddress] [nvarchar](max) NULL,
	[City] [nvarchar](max) NULL,
	[ZIP] [nvarchar](max) NULL,
	[Country] [nvarchar](max) NULL,
	[VAT] [nvarchar](max) NULL,
	[FiscalCode] [nvarchar](max) NULL,
	[Email] [nvarchar](max) NULL,
	[PEC] [nvarchar](max) NULL,
	[Phone] [nvarchar](max) NULL,
	[PriceList] [nvarchar](max) NULL,
	[Discount] [nvarchar](max) NULL,
	[PaymentTerms] [nvarchar](max) NULL,
	[LastModifiedDate] [datetime] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
```

<figure><img src="/files/qWI9CPbp42PdhcWRpGj8" alt="" width="290"><figcaption></figcaption></figure>

{% hint style="info" %}
To optimize the integration, prepare a custom view in SQL with the data you want to integrate on HubSpot Companies. To this view, you can add or remove fields at any time, perform format conversions (casts) and correctly manage the entries of the properties checkboxes, multiple checkboxes, dropdown select, radio select and HubSpot user.
{% endhint %}

### General Information

<table><thead><tr><th width="213">About this company</th><th width="298">Details</th><th>Field type on HubSpot</th></tr></thead><tbody><tr><td>ERPCode</td><td>Custom field created to match HubSpot and ERP records, captures the ID code of the record from the ERP</td><td>Single-line text</td></tr><tr><td>CompanyName</td><td></td><td>Single-line text</td></tr><tr><td>VAT</td><td></td><td>Single-line text</td></tr><tr><td>FiscalCode</td><td></td><td>Single-line text</td></tr><tr><td>Email</td><td></td><td>Single-line text</td></tr><tr><td>PEC</td><td></td><td>Single-line text</td></tr><tr><td>Phone</td><td></td><td>Phone number</td></tr></tbody></table>

### Geographical Information

<table><thead><tr><th width="515">Geographical Information</th><th>Field type on HubSpot</th></tr></thead><tbody><tr><td>StreetAddress</td><td>Single-line text</td></tr><tr><td>City</td><td>Single-line text</td></tr><tr><td>ZIP</td><td>Single-line text</td></tr><tr><td>Country</td><td>Dropdown select</td></tr></tbody></table>

### ERP Information

<table><thead><tr><th width="241">HubSpot Property Name</th><th width="279">Details</th><th>Field type on HubSpot</th></tr></thead><tbody><tr><td>PriceList</td><td>The price list information we want to transfer to HubSpot</td><td>Dropdown select</td></tr><tr><td>Discount</td><td></td><td>Dropdown select</td></tr><tr><td>PaymentsTerms</td><td></td><td>Dropdown select</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://howto.erpbridge.io/readme/companies/synchronization-from-hubspot-to-erp/recommended-synchronization-sql-from-hubspot-to-database.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
