in my database we have a field which is going beyond int max value,
i can choose bigint for primary key but i am wondering can we use decimal(2,18) for primary key and if we can than how we auto increment this field ?
in my database we have a field which is going beyond int max value,
Share
You may have a decimal as a primary key, but it must have a scale of 0.
SQL Server will handle the auto-incrementing.
Example:
Reference: http://beyondrelational.com/modules/2/blogs/28/posts/10331/sql-server-what-are-the-data-types-supported-in-identity-columns.aspx
See your master plan in action here: http://sqlfiddle.com/#!3/e491d/1/0