From C#, using ADO, or through direct SQL, how would I Alter an existing
column to add or remove Identity from it?
One path would be:
(a) create a new table
(b) copy the data over
(c) add the identity property if it wasn't there before and you're adding
it; leave as is, without the identity property, if it was there before and
you're dropping it.
(d) drop the old table (you might have to drop relationships and other
dependencies)
(e) rename the new table to the old name
(f) don't forget to re-create primary key, indexes, constraints, triggers,
etc.
As you can imagine, for larger tables, this will be quite prohibitive if you
expect to perform the task synchronously from C#. If this is a web app, it
is doubtful the browser will succeed without timing out.
How does Enterprise Manager do it?
Profiler will tell you exactly how, but I can tell you this, it's not a
simple statement (at the very least it will make a complete copy of the
table).
Realistically now, how many times are you going to be dropping and adding
the IDENTITY property on existing columns in a table?