# Extracting XML from Keyfax tables

We are often asked, particularly by integration engineers, how to access information relating to **Startup** or **Export** data. Typically, data is held in XML documents which can be difficult to read. Using SQL Server Management Services (SSMS) it is possible to view either **Session** or **History** data.

### Session Data

Here we are looking at session data from the **seSessionValues** table. Other tables holding XML content are syOrder (repair orders) and syTaskHistory (repairs and enquiries).

To retrieve the latest **Startup XML** the following provides clickable links.

```sql
SELECT DateTime, GUID, Name, CONVERT(xml, REPLACE(CAST(Data AS NVARCHAR(MAX)), ' encoding="utf-8"', ''))
FROM seSessionValues WITH (NOLOCK)
WHERE Name = 'Startup'
ORDER BY DateTime DESC
```

Run the results into a Grid and the hyperlinks will be presented; clicking each will open the formatted XML document in a new tab:

<div align="left"><figure><img src="/files/aUbRw6yt2EO9dBrJiCDL" alt=""><figcaption><p>seSessionValues sample data</p></figcaption></figure></div>

**Export XML** can be extracted as follows:

```sql
SELECT DateTime, GUID, Name, CONVERT(xml, REPLACE(CAST(Data AS NVARCHAR(MAX)), ' encoding="utf-8"', ''))
FROM seSessionValues WITH (NOLOCK)
WHERE Name = 'EXPORT_XML'
ORDER BY DateTime DESC
```

### History Data

Depending on your configuration, this will involve two main tables **syOrders** and **syTaskHistory**:

```sql
SELECT * FROM syOrder WITH (NOLOCK) ORDER BY Created DESC
 or
SELECT * FROM syTaskHistory WITH (NOLOCK) ORDER BY Created DESC

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.keyfax.biz/product-suite/admin/best-practices/extracting-xml-from-keyfax-tables.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
