How to control order of assignment for new identity column in mssql ?

Posted by alpav on Stack Overflow See other posts from Stack Overflow or by alpav
Published on 2010-03-15T19:56:35Z Indexed on 2010/03/15 19:59 UTC
Read the original article Hit count: 302

I have a table with CreateDate datetime field default(getdate()) that does not have any identity column.

I would like to add identity(1,1) field that would reflect same order of existing records as CreateDate field (order by would give same results). How can I do that ?

I guess if I create clustered key on CreateDate field and then add identity column it will work (not sure if it's guaranteed), is there a good/better way ?

I am interested in sql 2005, but I guess the answer will be the same for sql 2008, sql 2000.

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server-2005