---
url: /flow/guide/scripting-reference/functions/database/getsqlvaluefromdest.md
---

# GetSQLValueFromDest

## Declaration

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

### Example

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

## Description

Returns a single value being the first field in aSQL query. It is more common to use [GetDataSetFromDest](/flow/guide/scripting-reference/functions/database/getdatasetfromdest) 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.
