SQL Server automatic numbering and comparison.
I. UseProgramObtain the database ID. Insert the obtained ID number when inserting the record. Advantage: flexible. Disadvantage: You need to interact with the database twice. When inserting data, you must execute "insert into tablename values (" & getmaxid & ", 'value')", where getmaxid is the function for obtaining the ID.
2. Use a database trigger to insert an ID number. Advantage: flexible. Fast. The disadvantage is that it is relatively complicated. You need to perform some program processing on the database. When inserting data, you only need to insert into tablename values (0, 'value.
Iii. Using the labels provided by SQL Server, you can easily implement automatic database numbers. The disadvantage is that it is not flexible and cannot meet the user's needs. The insert into tablename (name) value ('value') must be used because the value cannot be inserted in the label column during record insertion ');. Advantages: simple operation and high speed
4. Add a seed field (ID) SQL Server automatic number field /////////////////////////////////// /////
Alter table Table1 add ID int identity (1, 1)