Sql Server CE - Temporary disable auto increment on a specific collum

Posted by Fábio Antunes on Stack Overflow See other posts from Stack Overflow or by Fábio Antunes
Published on 2010-04-21T15:29:41Z Indexed on 2010/04/21 15:43 UTC
Read the original article Hit count: 564

Filed under:
|
|

Hi guys.

I have this little question, thats been on my head for while now.

Here it goes:

Is it possible to temporary disable the Auto_Increment on the collum ID.

So that i can add a new row to the table and being able specify the ID value when inserting the row.

And then in the end enable the Auto_Increment again, and let do its work as usual?

And if its possible how can i do it.

The Table structure is very simple

Collum Name (atributes)

ID (Primary Key, Auto Increment, int, not null)

Name (nvarchar(100), not null)

Notice:

  • The table name is: People.

  • Lets also consider that the table already has data and cannot be changed.

  • The database server is SQL Server CE.

  • The SQL commands will be executed in a C# program, if its of any help.

I really hope its possible, it would come very handy.

Thanks

© Stack Overflow or respective owner

Related posts about sql-server-ce

Related posts about auto-increment