---
url: >-
  /statelake/scripting-reference/functions-and-procedures/database-functions/getsqlvaluefromdest.md
---

# GetSQLValueFromDest

This function returns a single value - being the first field in an **aSQL** query.

It would be more common to use the **GetDataSetFromDest** function to return multiple values - this saves re-querying the database to retrieve multiple fields from a single record.

The **SQL** query is executed against a **DB Connection** on the **Destination** of the **Map**.

**aDBIndex** indicates which of the **DB Connections** is used based on its zero based index.

Declaration: function GetSQLValueFromDest(const aSQL: string; aDBIndex : integer): variant;

The example follows.

```pascal
procedure OnMapEvent(var Value:Variant);
begin
  Value := GetSQLValueFromDest('select name from dr_accs where accno=1',0);
end;
```
