Can I set up an auto-increment on an id field in sql server that will double the id with each row?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, you can only increment arithmetically (by adding) and not geometrically (by multiplying).
Such a feature would not be useful anyway. If the first row has the value of 1, and you multiply by 2, the row values would be 1, 2, 4, 8,… 18446744073709551616 for the 64-th row.
That last value is too big to fit in a
bigintcolumn, so you could only store up to 63 rows per table.If you do need less than 64 rows, then it’s not too much of a hassle to turn off the autoincrement on the primary key, and just use set values.