# dbQuery with multiple statements

**URL:** <https://community.cdata.com/t/dbquery-with-multiple-statements/1247>\
**Category:** CData Arc\
**Tags:** sql, question, dbquery, arcscript, sql-server\
**Created:** [December 3, 2025, 6:27pm UTC](https://community.cdata.com/t/dbquery-with-multiple-statements/1247 "2025-12-03T18:27:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Travis](https://avatars.discourse-cdn.com/v4/letter/t/bbce88/32.png) [@Travis](https://community.cdata.com/u/Travis)\
**Post date:** [December 3, 2025, 6:27pm UTC](https://community.cdata.com/t/dbquery-with-multiple-statements/1247/1 "2025-12-03T18:27:02Z")

</div>

How can I get this Sql Server dbQuery to work? The INSERT is completing fine, but I need to get the inserted identity PK and Arc is not picking it up.

```xml
<arc:set attr="db.query">	insert into table (...) values (...); select SCOPE_IDENTITY();</arc:set><arc:call op="dbQuery" in="db" out="results"> ...

```

Is there a better way to get the identity?

(I have to use ArcScript, the upsert connector is not an option)

---

<div class="post-metadata">

**Author:** ![lohith](https://sea3.discourse-cdn.com/cdata/user_avatar/community.cdata.com/lohith/32/1848_2.png) [@lohith](https://community.cdata.com/u/lohith)\
**Post date:** [December 24, 2025, 12:16pm UTC](https://community.cdata.com/t/dbquery-with-multiple-statements/1247/2 "2025-12-24T12:16:48Z")

</div>

Hi Tavis,

The updated script would look like below:

```auto
<arc:set attr="db.query">	insert into table (...) OUTPUT INSERTED.<columnName> values (...); </arc:set><arc:call op="dbQuery" in="db" out="results"> ...

```

Here the column name refers to the PK column or any column you would like return on successful insert.

Let me know if this works for you?
