Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Primary key and auto-int
Message
From
14/04/2010 13:44:44
 
 
To
14/04/2010 13:07:46
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01460172
Message ID:
01460180
Views:
63
>I have a field PrimaryKey
>
>It's type is auto-int
>
>Is it possible for me to erase everything in that table and start over with 1 as the first value for the first
>record instead of what the counter is giving me by default?


Denis,

A zap does not reset the next autoinc value

You need to do that with alter table after the reset (it's mentioned in the help)
	set safety off
	
	create cursor pp ;
	(	pp I  autoinc nextvalue 0, ;
		qq I ;
	 )
	
	
	insert into pp (qq ) values (1)
	insert into pp (qq ) values (2)
	?pp && 1
	
	zap
	insert into pp (qq ) values (1)
	insert into pp (qq ) values (2)
	?pp && 3
	
	zap
	alter table pp  ;
		alter pp  I  autoinc nextvalue 0
	

	
	insert into pp (qq ) values (1)
	insert into pp (qq ) values (2)
	?pp && 1
	
Gregory
Previous
Reply
Map
View

Click here to load this message in the networking platform