🎉 Celebrate with 10% OFF on All Products! Use Code: GFEX10 Or Buy Any 2+ Items for 30% OFF with Code: GFEX30!

Gravity Forms Mssql Db Integration Add-on

Updated 12 min read Gravity Forms Files, Storage & Databases
On this page
  1. Before you buy: your server needs a SQL Server driver
  2. What you can do
  3. Step 1: Prepare the database user
  4. Step 2: Connection settings
  5. Step 3: Create a feed
  6. Insert, update and no double rows
  7. Column mapping
  8. Column types and values
  9. Sending, retries and bulk send
  10. Developer hooks
  11. Troubleshooting
  12. Frequently asked questions

The Gravity Forms MSSQL DB Integration Premium Add-on writes every Gravity Forms entry as a row into a table of your own Microsoft SQL Server or Azure SQL database. You choose the table, map form fields to columns (or let the add-on build the columns from the form), decide whether a new entry is inserted or updates an existing row, and the add-on retries when the database is down, without ever blocking the form.

Before you buy: your server needs a SQL Server driver

The add-on talks to SQL Server through the Microsoft PHP driver. Your web server must have one of these PHP extensions, together with the Microsoft ODBC Driver for SQL Server (version 17 or 18):

  • pdo_sqlsrv (used first when present)
  • sqlsrv (used when pdo_sqlsrv is not there)

Most shared hosting does not offer these extensions. They are normally available on a VPS, a dedicated server or a managed WordPress host that lets you install PHP extensions. Without the driver the add-on cannot write anything: it shows a notice in the WordPress admin saying so, and your forms keep working as before. Ask your host, or look at Tools, Site Health, Info, Server, for pdo_sqlsrv or sqlsrv. The add-on does not install the driver.

The add-on also needs WordPress 5.8 or newer, Gravity Forms 2.5 or newer and PHP 7.4 or newer (tested on PHP 7.4 and 8.3). The database can be SQL Server on your own network or in the cloud, Azure SQL Database or Azure SQL Managed Instance; it must accept SQL Server logins (user name and password) and be reachable from your web server (firewall rules).

What you can do

  • One row per entry in a table you name (Leads or dbo.Leads or sales.Leads).
  • Map fields to columns: choose the column name and the source (a form field, one input of a Name or Address field, entry details such as the entry ID or the date created, or a custom value with merge tags), or let the add-on build the columns from the form.
  • Create the table and add columns when they are missing (optional; existing columns are never changed or removed).
  • Insert or update: a plain insert, or an update on a key column with MERGE (a row with the same key is updated, otherwise a row is added).
  • No double rows: an optional entry reference column with a unique index makes sure the same entry is never inserted twice, even when a send is repeated.
  • Retry when SQL Server is down (up to 6 tries over about 14 hours), with the result in the entry notes.
  • Send old entries from the entry list with a bulk action.
  • Conditional logic on every feed, several feeds per form.
  • Test connection button on the settings page.
  • Encrypted connection (Encrypt and TrustServerCertificate options) and a password stored encrypted.

Step 1: Prepare the database user

Make a SQL Server login and a database user for WordPress. Give it only what the feeds need:

You wantThe user needs
Insert rows into an existing tableINSERT on the table (and the right to see the table; SELECT is the simplest way)
Update rows on a key (MERGE)SELECT, INSERT and UPDATE on the table
Let the add-on create the table, add columns and make the unique indexCREATE TABLE in the database, and ALTER on the schema (the owner of the table can also do it)

If your server uses a firewall (Azure SQL firewall, a cloud security group or Windows Firewall), allow the IP address of your WordPress web server on the SQL Server port (1433 unless you changed it).

Step 2: Connection settings

Go to Forms, Settings, MSSQL DB. First enter your Gravity Extra licence key. Then fill in:

SettingWhat to enter
HostThe server name or IP address, or an Azure SQL name such as myserver.database.windows.net (a leading tcp: is accepted). For a named instance write HOST\INSTANCE and leave the port empty.
PortDefault 1433. Leave empty for a named instance.
Database NameThe default database of the connection.
Default schemaUsed for a table typed without a schema. Default dbo.
Username and PasswordA SQL Server login. The password is stored encrypted (libsodium, or AES-256-GCM when libsodium is missing) with a key made from your WordPress salts, and it is never shown again. If you change the authentication keys in wp-config.php, enter the password again. Windows (integrated) authentication and Microsoft Entra sign-in are not supported.
Encrypt the connection (TLS)Off; On, and check the server certificate (Encrypt=1, TrustServerCertificate=0, recommended; Azure SQL needs encryption); or On, and trust the server certificate (Encrypt=1, TrustServerCertificate=1) for a server with a self-signed certificate.
When to writeBy default entries are written in the background, a moment after the form is sent, with retries. Tick the box to write while the visitor waits (no retries then; a failure is shown in the entry notes).

Click Test connection. It uses the values on the screen, including a password you just typed, and shows the server version, the database and whether the connection is encrypted. A wrong password or a closed firewall is shown with the error number SQL Server returned (the password is never shown).

MSSQL DB settings with host, port, database, schema, user, password and the Test connection button
Figure 1: Forms, Settings, MSSQL DB: the connection settings.

Step 3: Create a feed

  1. Open your form, then Settings, MSSQL DB, Add New.
  2. Give the feed a name and the Table Name: Leads or dbo.Leads (schema.table). Square brackets are accepted. A name with three parts (database.schema.table) is not accepted: use the Database field instead.
  3. Database (optional): leave empty to use the database of the settings; another database on the same server needs the same user.
  4. Choose the Module: Insert Row or Insert or update the row (MERGE on a key column).
  5. Choose how the columns are made: I choose the columns (Column Mapping) or Build the columns from the form fields.
  6. Tick Create the table and add new columns if the add-on may do that, or leave it off when you manage the table yourself.
  7. Optionally set Enable Condition (conditional logic) and save.
List of MSSQL DB feeds for a form with the table and the module
Figure 2: The feeds of a form.
MSSQL DB feed settings with table, module and column mapping
Figure 3: A feed: table, module and column mapping.

Insert, update and no double rows

  • Insert Row adds a row for every entry. Fill in Entry reference column (optional) with a column name (for example gf_ref) and the add-on stores a code such as gf3-e120-f5 (form, entry, feed) in it and puts a unique index on it. If that entry is sent again, SQL Server refuses the second row, the add-on recognises its own code and the entry note says Row already in SQL Server table (not inserted twice). Without a reference column a repeated send adds another row.
  • Insert or update the row needs a Key column (one of the mapped columns, for example email or entry_id). The add-on sends one MERGE ... WITH (HOLDLOCK) statement: a row with the same key is updated, otherwise a row is inserted. The key column needs a unique index; with table maintenance on, the add-on creates it (a text key column is made NVARCHAR(191) so it can be indexed; a long text column that already exists cannot be indexed and SQL Server refuses it). An entry whose key is empty is not written and the note says why.

Column mapping

In I choose the columns mode each line has a Column Name and a source. Sources are the form fields (a Name or Address field offers each of its inputs), the entry details (Entry ID, Form ID, Date created in UTC, Source URL, User ID, Payment status, Payment amount, Transaction ID, IP address) and custom values where you can type text with merge tags. In Build the columns from the form fields mode every field becomes a column named from its label (customer_name, lower case with underscores) or from its ID (field_3); tick the entry details you want as extra columns (the IP address is personal data: tick it only when you need it). Fields without an answer (HTML, section, page, captcha, password) are skipped.

Column types and values

The add-on looks at the real type of every column in your table and sends each value in the matching form. When it creates a column it uses:

Gravity Forms fieldColumn type createdWhat is stored
Text, email, radio, select and most othersNVARCHAR(255)The text, any language
Paragraph text, address, file URLsNVARCHAR(MAX)The text
Number, quantity, total, priceFLOATThe number (thousands separators and the decimal comma of the field are understood). Text that is not a number is stored as NULL.
DateDATEYYYY-MM-DD, read with the date format of the field
TimeTIME(0)HH:MM:SS (24 hour)
ConsentBIT1 or 0
Checkboxes, multi select, list, several filesNVARCHAR(MAX)A JSON list such as ["Data","Ops"], or comma separated text if you choose that in the feed
Entry ID, user IDBIGINTThe number
Date createdDATETIME2(0)UTC, sent as ISO 8601 (2026-03-25T14:30:05), which SQL Server reads the same way in every language setting

An empty answer is stored as NULL. Every column the add-on creates can be NULL, and a table made by the add-on gets an id BIGINT IDENTITY primary key (unless you map a column called id). Existing columns are never changed or removed. If your own table has other column types (for example an INT or a DATETIME), the values are converted for them; a value that does not fit (a text longer than the column, for example) stops that entry with a clear note and the other entries go on.

Sending, retries and bulk send

  • The form is never blocked. When the visitor sends the form, the add-on only queues the write (a WordPress background event). The database is called a moment later, not while the visitor waits. The database being down, slow or unreachable does not slow down or break the form.
  • Retries. A connection that cannot be made, a lost connection, a deadlock or a busy Azure database is tried again 1 minute, 5 minutes, 30 minutes, 2 hours and 12 hours later (6 tries in all). Errors that cannot go away by themselves (wrong password, missing table, a value that does not fit, no right on the table) stop at once and are written in the entry notes with the SQL Server error number and a hint. WordPress background events run when your site gets a visit (or from a server cron job): on a very quiet site a retry can come later than planned.
  • No double inserts. A feed with a reference column or an update key can be tried again safely. When the connection is lost while a row is being written, the add-on cannot know whether SQL Server saved it: with a reference column or a key it simply tries again (the second try changes nothing if the first one worked); without one it does not try again and the note says write not confirmed, so you can look at the table.
  • Send old entries. In Forms, Entries choose entries (or all), then the bulk action Send to SQL Server (skip entries already sent). Entries already written are skipped. For feeds with a reference column or an update key there is also Send to SQL Server again, which writes the entries once more (updating the row or finding it already there). Writes are done in small batches in the background.
  • Results are written as notes on every entry: the table, and whether a row was inserted, inserted or updated, or already there.
Entry with the note Row inserted into SQL Server table
Figure 4: Every entry gets a note that says what happened in SQL Server.

Developer hooks

Change the values before they are sent. Return the array with column names as keys; a key that is not a mapped column is added as a column (it must exist in the table, or table maintenance must be on):

add_filter( 'gform_mssql_db_columns_pre_send', function ( $columns_data, $feed, $entry ) {
	$columns_data['CreatedBy']  = 'GravityForms_Connector';
	$columns_data['SourceIp']   = $entry['ip'];
	return $columns_data;
}, 10, 3 );

Run code after a row was written. $action is inserted, upserted or exists:

add_action( 'gform_mssql_db_post_process', function ( $action, $entry, $feed ) {
	GFAPI::add_note( $entry['id'], 0, 'MSSQL Database', 'SQL Server: ' . $action );
}, 10, 3 );

Troubleshooting

What you seeCauseWhat to do
The admin notice says the SQL Server driver is missingNeither pdo_sqlsrv nor sqlsrv is loaded in PHPInstall the Microsoft Drivers for PHP for SQL Server and the ODBC Driver on a server where you can do it, or ask your host. Most shared hosting cannot.
Error 18456, login failedWrong user name or password, or the server does not allow SQL Server loginsCheck the login; enable mixed mode authentication on the server.
Error 4060The user cannot open the databaseCheck the database name and that the user is mapped to the database.
Error 53, -1, 258, 10060The server cannot be reached or does not answerCheck host and port, and open the firewall for your web server IP address.
Error 40615The Azure SQL firewall blocks your web serverAdd the IP address of your web server to the Azure SQL server firewall.
The certificate is not trusted (connection error with TLS on)The server certificate is self-signed or from a private authorityInstall the certificate on the web server, or choose On, and trust the server certificate.
Error 208 or “table does not exist”The table is not thereCreate it, or tick Create the table and add new columns.
Error 207 or “has no column”A mapped column is not in the tableFix the name or tick table maintenance.
Error 229 or 230The user has no right on the table or a columnGrant INSERT (and SELECT, UPDATE for an update feed).
Error 8152A value is longer than the columnMake the column longer, for example NVARCHAR(MAX).
Error 2601 or 2627The row repeats a value of a unique columnUse a reference column or an update key, or remove the duplicate.
Error 1919A key column is a long textUse a key column of NVARCHAR(191) or shorter.

Frequently asked questions

Does it work on shared hosting? Usually not: shared hosts rarely have the Microsoft PHP driver. Check with your host before you buy.

Does it support Azure SQL? Yes. Use the server name name.database.windows.net, a SQL login, and turn on On, and check the server certificate. Add your web server IP address to the Azure SQL firewall.

Can it call stored procedures, or use Windows or Microsoft Entra sign-in? No. The add-on writes rows to tables with INSERT or MERGE and signs in with a SQL Server login.

Does it read data back from SQL Server into the form? No. It writes entries only. (It reads the column and index list of the table it writes to.)

What happens when I delete an entry in WordPress? The row in your database stays; delete it there if a person asks to be erased. The add-on adds this to the WordPress privacy policy guide.

Is the SQL safe from injection? Form values are never written into the SQL text: they are sent as bound parameters. Table and column names are written between square brackets with every closing bracket doubled.

Upgrading from version 1.0.x (which did not connect to a database): install the 2.0.0 zip over the old plugin once, then enter your licence key under Forms, Settings, MSSQL DB. Your saved connection settings are kept (the password is encrypted on the first admin visit) and your old feeds keep working: they now really insert into the table you named, and they do not create or change tables unless you tick the option. From 2.0.0 on, updates arrive in the WordPress dashboard.

Still need help?

Our support team answers tickets every day, usually within a few hours.

0
0
Your Cart
Your cart is emptyReturn to Shop
🔥 FREQUENTLY BOUGHT TOGETHER
Complete Combo & Save 40%!
ITEM IN YOUR CART
Gravity Forms Klaviyo Add-on
$39.00/yr
+
🎁 RECOMMENDED ADD-ON SAVE 40% OFF
Original Price: $39.00/yr
Bundle Special Price: $23.40/yr