How to automatically create the primary key that has the following series A001000001 … A001xxxxxx in SQL?
问题 I want to create a primary key(auto-increment) which is start with A001000001 . Here A001 would be constant and 000001 would be iterate. I want rows like this: How can I do it using SQL query? 回答1: For SQL Server (you didn't clearly specify which RDBMS you're using), my suggestion would be: add a INT IDENTITY column to your table - and quite frankly, I would make that column the primary key add a computed column to your table that does this "prefixing" Something like: CREATE TABLE dbo