Created
March 23, 2023 20:22
-
-
Save Orbis25/962d2e9edd9eb28df28019aceb96b3b5 to your computer and use it in GitHub Desktop.
Generate a unique code in sql autoincrement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE [TABLE_NAME]( | |
Id UNIQUEIDENTIFIER PRIMARY KEY NOT NULL, | |
[Index] INT IDENTITY(1,1) NOT NULL, | |
[Code] AS ('P'+ RIGHT('00000' + CAST(([Index]) AS VARCHAR(5)), 5)) PERSISTED, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment