Home Forums SQL Server 2008 SQL Server Newbies IDENTITY_INSERT, and Using Alphanumeric Autoincrement Primary Key RE: IDENTITY_INSERT, and Using Alphanumeric Autoincrement Primary Key

  • Steven Willis (6/26/2013)


    Here's the article that I saw lately. I've only skimmed through it but it looks to do the sort of ordering we've been talking about. Looks interesting.

    SQL2012 Varchar Sequences

     

     

    That is interesting. I don't think however it does quite what the OP is trying to do. You will notice in the example code here:

    ADD CONSTRAINT Const_Sample_Seq

    DEFAULT FORMAT((NEXT VALUE FOR dbo.Sample_Seq),'CUS0000#') FOR [ID];

    This is simply converting the numeric sequence to a varchar and appending the hardcoded "CUS0000" in front of the number. The character portion of this is static, and it is the hard part of using an "incrementing" alphanumeric. I don't see anywhere in this example of doing things like A1, A23, B4, etc.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/