# How to reset autocounter()

**URL:** <https://techcommunity.softwareag.com/t/how-to-reset-autocounter/192802>\
**Category:** Forum\
**Tags:** Adabas-Natural, Adabas, Adabas-Add-on-Products, SQL-Access, Mainframe-Integration, CONNX\
**Created:** [January 19, 2017, 9:55pm UTC](https://techcommunity.softwareag.com/t/how-to-reset-autocounter/192802 "2017-01-19T21:55:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Min\_Chai](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@Min\_Chai](https://techcommunity.softwareag.com/u/Min_Chai)\
**Post date:** [January 19, 2017, 9:55pm UTC](https://techcommunity.softwareag.com/t/how-to-reset-autocounter/192802/1 "2017-01-19T21:55:05Z")

</div>

I did an sql like this:

select autocounter() from customers {maxrows 3}

I get 3 rows with number 1, 2, 3

I then rerun the select and now I get 3 rows back with 4,5,6.

How can I get autocounter() to reset back to 1,2, and 3 with my subsequent run of the select statement?

Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [January 19, 2017, 10:04pm UTC](https://techcommunity.softwareag.com/t/how-to-reset-autocounter/192802/2 "2017-01-19T22:04:30Z")

</div>

There is currently no way to reset the counter back to one. The function was created as an easy way to generate a unique identifier. It is a long integer, and will wrap back around to 0 once it reaches the max.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [February 1, 2017, 7:24pm UTC](https://techcommunity.softwareag.com/t/how-to-reset-autocounter/192802/3 "2017-02-01T19:24:45Z")

</div>

My prior response was not correct. It is possible to reset the counter by using the following SQL statement:

{resetcounter}

Additionally, if you want to seed the counter to a specific value you can use this SQL statement:

{setcounter 123}

Where 123 can be any value.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:37pm UTC](https://techcommunity.softwareag.com/t/how-to-reset-autocounter/192802/4 "2021-04-02T15:37:47Z")

</div>


