# 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="https://489586434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fft3Wb1b95o4TJkgnx8qk%2Fuploads%2Fgit-blob-a56f38caa0b986dcacca44f9104a597993433992%2Fimage%20(7).png?alt=media" 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>
