Thursday, August 09, 2007

Making a normal Column, an Identity column in SQL Server CE

In SQL CE making a normal column an identity column is not possible. This is because the process involved in the making of identity columns. If you would like to know more about the Identity creation behaviour please read my earlier article.

http://arjunachith.blogspot.com/2007/08/making-normal-column-identity-column-in.html

In SQL CE the process mentioned in the article is not possible because that SQL CE does not support enabling and disabling IDENTITY INSERT.

If you did try it out, should have noted that even SQL CE table editor is not supporting this.

So if you really want to change a column in to an identity column (which already having unique values) then what you can do is, create a new table and copy the data your self. But the problem is that you will not get the old values in the identity column because there is no way to copy them without turning the IDENTITY INSERT off. So identity column data will be new from 1 to n, But all other information will be there in the table with the identity column in place. If you even wants to keep the old identity values you can keep that old identity column and create a new column for the Identity column.

No comments: