December 26, 2005

To use identity column in MS SQL Server or not

Many of my colleagues always avoid to use identity column, this I mean things like identity(1,1) column, in their database design. One of their point is copying a table with such a column will fail as MS SQL Server doesn't support. Well, I also knew the point as I encounter so many failures in importing/exporting tables while having no idea such a column is involved.
 
However, if we are copying data between two databases, identity column is not a problem at all as I tested this morning. There is a copying objects function in the data import/export wizard, selecting this will always work regardless of your column types.
 
One more thing, SQL Server prompted an error of BACKUP LOG on the destination database when a normal database user is used to executed the duplication. The issue was gone when I used "sa" instead.

No comments: