How to setup a column to auto-increment
-
Hello, I have an identity column that is set up to auto-increment via the "Identity Increment" property for the column. This is working fine. However, I have another column that I'm calling "Sequence". This is not an identity column, it just specifies the position of each record which is subject to change. I want to set up the column to auto-increment so I don't have to manually enter the Sequence number for each record I add. Is there a way to set up a column to auto-increment without making the column an Identity column, and still allowing me to manually change the Sequence numbers later if I want? BTW: I'm adding data to the table in Microsoft SQL Server Management Studio. Thanks! Ian
-
Hello, I have an identity column that is set up to auto-increment via the "Identity Increment" property for the column. This is working fine. However, I have another column that I'm calling "Sequence". This is not an identity column, it just specifies the position of each record which is subject to change. I want to set up the column to auto-increment so I don't have to manually enter the Sequence number for each record I add. Is there a way to set up a column to auto-increment without making the column an Identity column, and still allowing me to manually change the Sequence numbers later if I want? BTW: I'm adding data to the table in Microsoft SQL Server Management Studio. Thanks! Ian
Use follwing: objCol.AutoIncrement = true; objCol.AutoIncrementSeed = 1; objCol.AutoIncrementStep = 1; objCol.ColumnName = "ID"; :)
-
Use follwing: objCol.AutoIncrement = true; objCol.AutoIncrementSeed = 1; objCol.AutoIncrementStep = 1; objCol.ColumnName = "ID"; :)
Thanks for the reply. I should have specified that I'm creating the table in Microsoft SQL Server Management Studio. These column properties don't seem to be exposed in the table designer. At least I can't find them... Ian
-
Hello, I have an identity column that is set up to auto-increment via the "Identity Increment" property for the column. This is working fine. However, I have another column that I'm calling "Sequence". This is not an identity column, it just specifies the position of each record which is subject to change. I want to set up the column to auto-increment so I don't have to manually enter the Sequence number for each record I add. Is there a way to set up a column to auto-increment without making the column an Identity column, and still allowing me to manually change the Sequence numbers later if I want? BTW: I'm adding data to the table in Microsoft SQL Server Management Studio. Thanks! Ian