更新时间:2023-09-24 23:13:46
你可以看看这个...
使用NVARCHAR / VARCHAR数据类型的自动递增ID [ ^ ]
您需要解决并需要根据您的要求进行更改。
试试这样CREATE TABLE dbo.TestTable
(ID INT IDENTITY ( 1 , 1 ) PRIMARY KEY ,
name int ,
FormatColumn AS RIGHT ( ' LS_00' + CAST(ID AS VARCHAR ( 8 )), 6 )PERSISTED
)
insert into TestTable(name) values ( 1 )
insert into TestTable(名称)值( 2 )
insert into TestTable(name) values ( 3 )
选择 * 来自 Tes TTable的
Dear i want to generate user specific auto increment code . like
i m creating a lead sheet . than when we submit and save it in database its id should be create like this : LS_001 for next entry . it should be , LS_002
can you please check it out this...
Auto-incremented ID with NVARCHAR/VARCHAR datatype[^]
you need to work around and need to change accordingly to your requirement.
Try like thisCREATE TABLE dbo.TestTable ( ID INT IDENTITY(1,1) PRIMARY KEY, name int , FormatColumn AS RIGHT('LS_00' + CAST(ID AS VARCHAR(8)), 6) PERSISTED ) insert into TestTable ( name) values (1) insert into TestTable ( name) values (2) insert into TestTable ( name) values (3) select * from TestTable