views:

276

answers:

2

Hi All I Use a Sql Server Compact Edition DataBase File For Store the Data in My Windows Application Software.In this DataBase I have A Table With Identity Field.When I Insert A Record To the Table, identity Code increment Automatically.But When I Delete All Records From Table,And Insert Records Again,Identity Field don't Start From 1. I Want Reset this Value to 1.

Please Help Me

+3  A: 

DBCC does not exist in CE. Try

create table t1 
(
id int identity,
val int
);

insert into t1 (val) values (1);
insert into t1 (val) values (2);

select * from t1


ALTER TABLE t1 alter column id
    IDENTITY (1,1)

insert into t1 (val) values (1);
insert into t1 (val) values (2);

select * from t1
cdonner
A: 
DBCC CHECKIDENT (mytable, RESEED, 1)

Btw, this is a duplicate of this one: http://stackoverflow.com/questions/510121/reset-autoincrement-in-sqlserver-after-delete

I would have posted this as comment by I've got no reputation.

The question was about SQL CE. Don't you dare closing it.
cdonner

related questions