For example, the column ID. I want it to start at 1, and then increment by 1 for each row.
Thank you!
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.
The
identity(1, 1)is what’s important here. The first argument represents the seed (meaning initial) value, the second argument represents the increment rate. This means that the first record will have a value of1, and each subsequent record will increment this value by1.Had we specified, for example,
(7, 2), the first record would have a value of7, then each record would increment by2(so7,9,11, and so on).Note that obviously the
primary keypart is not required, but the identity column in a table (if it has one) is usually the primary key. If it isn’t in your case, then just remove that portion.