Home > Software engineering >  Consult ace [for], how to increase a s_id field for its own table, and the field will be automatical
Consult ace [for], how to increase a s_id field for its own table, and the field will be automatical

Time:10-14

Consult ace, how to increase a s_id field for its own table, and the field will be automatically generated a series of specified number, (does not require the use attribute is set to automatic numbering), such as the fields in the table have s_no, s_name... , there are some data, now need to add a s_id field to the table, and update the values for this field, the value for the similar serial number, to a specified data value as the first serial number, the following is according to the value of a + 1 to update, such as according to the requirements are numbered starting from 35051
Such as:
S_id s_no s_name
35051 001 Chen Wang
35052 002 Liang Song
35053 king cover 003
35054 004 spirit

.

.

.
I say you can understand clearly, please your timely help, thank you! Thank you very much

CodePudding user response:

SQL server has a rownumber function can realize the request of you, your Google,
Access your cycle,

CodePudding user response:

Want to use the code realization,

Build another table, for example, only one field, a record, the next number is 1 pet table, each time you add a record, update this table,

Don't adopt the method of cyclic update the original table number field, because the newly added record is not necessarily at the end of the recordset (unless the query in the Order By s_id, is numeric and s_id), each loop refresh causes changes in the serial number corresponding relation,

If does not require the serial number is continuous, after deleting records just to maintain the uniqueness, might as well use the built-in automatic numbering properties,

CodePudding user response:

reference 1st floor caozhy response:
SQL server has a rownumber function can achieve your requirements, your Google,
Access your cycle,

The yuan fang said

CodePudding user response:

Copy and paste the data into EXCEL directly,
In the front of a column, then you can drag ways, will be completed in the first column filled with,
Finally is to copy and paste back to the table, of course, to empty the paste again,
  • Related