Wednesday, March 7, 2012

Can Auto-increase field

There is a key in the datebase is auto-increase field.
I have a prolem of it. does it have upper boundary of auto-increase?if has, how I change to let it has not upper boundary

I assume you’re referring to identity columns. SQL Server ensures that a unique, incremental value is provided when a row is added.

The identity column’s value is limited only by the numeric limits of the type you choose and the seed and increment values you specify. Consider the following:

MyIdentity int identity (1, 1)

Values will be assigned beginning with 1 and increasing to an upper limit of 2,147,483,647. If you’re concerned about running out you have two options: (a) increase the size of the column (e.g. use bigint) or (b) use a seed value less than 1. For example, to get the most out of the identity column without increasing its size you can use the following:

MyIdentity int identity (-2147483648, 1)

If this is still too prohibitive then you may want to consider using the uniqueidentifier type.

Cheers,
Kenny Kerr

http://weblogs.asp.net/kennykerr/

No comments:

Post a Comment