---
schema_version: "1"
id: 927ea1f9947750f2100f528164e70c65e120c9ec9902a9a13518d8f57da57537
title: InsertData()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud/ampscript/references/data-extension/mc-ampscript-reference-data-extension-insert-data.md
canonical_url: https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-data-extension/mc-ampscript-reference-data-extension-insert-data.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 93a08fe161ee18d4f4560447022c3184dc19b092af8a243b2b87f6053e6e7886
products:
  - AMPscript for Marketing Cloud
  - Marketing Cloud
---
# InsertData()

Inserts rows into a data extension, and returns the number of rows inserted.

Use this function in CloudPages, landing pages, microsites, and SMS messages in Mobile Connect. Use the `InsertDE()` function to insert rows into a data extension from emails.

## Availability

<table>
  <tr>
    <td>Marketing Cloud Engagement</td>
    <td>✅ Yes</td>
  </tr>
  <tr>
    <td>Marketing Cloud Next</td>
    <td>❌ No</td>
  </tr>
</table>

## Syntax

```
InsertData(dataExt,
           columnName1, valueToInsert1,
           [columnName2, valueToInsert2 ...])
```

The `InsertData()` function has three parameters:

- `dataExt` (string): Required. The name of the data extension that you want to insert data into.
- `columnName1` (string): Required. The name of the column to insert into the data extension.
- `valueToInsert1` (string): Required. The value to insert into the specified column.

You can insert multiple values into a row by appending column names and field values to the end of the function.

## Usage

To use the function, first pass it the name of the data extension that you want to insert data into. Next, pass it the name of the column to insert data into. Finally, pass the data that you want to insert into the specified column.

Imagine you have a Flights data extension that contains the data in this table.

| FlightId | Origin | Dest | Price | PerBagSurcharge |
| -------- | ------ | ---- | ----- | --------------- |
| 1        | IND    | NYC  | 100   |                 |
| 2        | IND    | LAX  | 200   |                 |
| 3        | IND    | SEA  | 500   | 25              |

To insert a new row, use this function.

```
%%[
  Var @newFlight
  Set @newFlight = InsertData("Flights", "FlightId", 4, "Origin", "IND", "Dest", "ORD", "Price", "125", "PerBagSurcharge", null)
  Output(v(@newFlight))
]%%
```

The function inserts the specified row. The data extension now contains this data.

| FlightId | Origin | Dest | Price | PerBagSurcharge |
| -------- | ------ | ---- | ----- | --------------- |
| 1        | IND    | NYC  | 100   |                 |
| 2        | IND    | LAX  | 200   |                 |
| 3        | IND    | SEA  | 500   | 25              |
| 4        | IND    | ORD  | 125   |                 |

The function returns `1`, indicating that it inserted one row.

## See Also

- [InsertDE()](https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-data-extension/mc-ampscript-reference-data-extension-insert-de.md)
