SQL server automatically numbered odd question:
I had in the SQL data, several of the ID column straight: 1 2 36 888888888
But I want to change it to automatic number (invoice number), when I changed. I joined several data for:
888888889 888888890 888888891
Where is the problem? And I have a letter to middle, such as: "gd021852052", should how? How to make the invoice number to zero?
Add:
SQL server automatically numbered three methods and comparison,
One, use the program for the database ID number, and inserted in the record of the time to get to the ID number of inserted, advantages: flexible, weakness: the need to interact with the database twice, when inserting data, you need to perform "insert into tablename values (" & amp; GetMaxID & amp; ", "value") ", in which the getMaxID for ID function,
Second, the use of database triggers insert ID number, advantages: flexible, relatively fast, the disadvantage is that is relatively complex, need some process on the database, when inserting data only need to insert into tablename values (0, 'value'),
Three, use the SQL Server can provide marked the automatic numbering of the implementation of the database, etc., defect is not flexible, degree may not meet the needs of user, and at the time of insert records due to the marked columns are not allowed to insert value, so you want to use insert into tablename (name) the value (' value '); , the advantages are: simple operation, fast speed
CodePudding user response:
I'm the!CodePudding user response:
Max () + 1?CodePudding user response:
To control with a serial number listCodePudding user response:
Are all very good advice! Worth learning