更新时间:2023-09-22 17:09:34
***参考:
http://www.sqlteam.com/article/custom-auto-generated-sequences-with-sql-server [ ^ ]
添加前缀/后缀。这样的东西应该有效:
1 - 添加一个IDENTITY字段,该字段将自动递增
2 - 添加一个计算字段表定义:
[InvoiceNo] AS('AS'+右(('000000000'+ CAST(idfield AS varchar(9))),9 )+'FAK')
这将给你invoiceno格式:
AS000000001FAK
AS000000002FAK
...
AS000995481FAK
adding a prefix/suffix. Something like this should work:
1 - Add an IDENTITY field which will be auto-incremented
2 - Add a calculated field in the table with the definition of:
[InvoiceNo] AS ('AS' + RIGHT(('000000000' + CAST(idfield AS varchar(9))), 9) + 'FAK')
This will give you invoiceno in the format of:
AS000000001FAK
AS000000002FAK
...
AS000995481FAK