Copy link to clipboard
Copied
Hi,
I need help with setting the identity to always start with 1 when new records are inserted.
My application is inserting records to Table A then at the end, all records in Table A are deleted.
When the next time this app. is ran, Table A is re-populated again and for certain reason the inserted record need to always start from 1.
The identity is set to automatic so I'm trying to find a way if I can reset the identity column before start inserting new records.
Is this doable?
This is not working:
<cfquery name="getRecs" datasource="myrec">
'identity', ', 0, '0' //reset identity???
INSERT INTO Table
Select a,s,c from tableB where a='a'
</cfquery>
Copy link to clipboard
Copied
Change the identity column so it's not automatic.
use select count(*) +1 from thetable as the identifier for new records.
Copy link to clipboard
Copied
assuming your db is sql server (it helps if you id your database when you ask
for help):
DBCC CHECKIDENT('tableA',RESEED,0)
0 because the db will +1 for the next INSERT.